2015-01-13 66 views
3

使用帶有KnpGaufrette和學說VichUploader當我嘗試使用以下安裝在我的Symfony2項目:循環引用在Symfony2中

問題:當我嘗試使用Gaufrette存儲適配器「doctrine_dbal」我得到以下錯誤:

[Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException]                                                     
Circular reference detected for service "doctrine.dbal.default_connection", path: "doctrine.orm.default_entity_manager -> doctrine.dbal.default_connection -> vich_uploader.upload_handler -> vich_uploader.storage.gaufrette -> knp_gaufrette.filesystem_map -> gaufrette.storage_fs_filesystem". 

一旦Symfony嘗試檢查配置,例如, on

app/console cache:clear 

我該如何解決這個問題?

我的設置

我的項目設置是symfony/framework-standard-edition2.5.*版本的默認設置,但不AcmeDemo捆綁。

我壓根兒通過作曲家添加軟件包:

composer require knplabs/knp-gaufrette-bundle vich/uploader-bundle 

...將它們添加到AppKernel的registerBundles()

//... 
$bundles = array(
     new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), 
     new Symfony\Bundle\SecurityBundle\SecurityBundle(), 
     new Symfony\Bundle\TwigBundle\TwigBundle(), 
     new Symfony\Bundle\MonologBundle\MonologBundle(), 
     new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), 
     new Symfony\Bundle\AsseticBundle\AsseticBundle(), 
     new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), 
     new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), 
     new AppBundle\AppBundle(), 
     new Vich\UploaderBundle\VichUploaderBundle(), //NEW 
     new Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(), //NEW 
    ); 
//... 

...並增加了以下配置config.yml,這是基於上的文檔VichUploader with GaufretteKnpGaufrette with Doctrine DBAL

# ... 
knp_gaufrette: 
    stream_wrapper: ~ 

    adapters: 
     storage_adapter: 
      doctrine_dbal: 
       connection_name: default 
       table: data_storage 
       columns: 
        key: id 
        content: file 
        mtime: mtime 
        checksum: checksum 

    filesystems: 
     storage_fs: 
      adapter: storage_adapter 



vich_uploader: 
    db_driver: orm 
    storage: gaufrette 

    mappings: 
     storage: 
      uri_prefix:   /images/products 
      upload_destination: storage_fs 
+0

爲什麼doctrine.dbal.default_connection服務對vich_uploader.upload_handler依賴?我會以此開始。 –

回答