2013-08-01 23 views
1

我具有低於理論結構,類「應用程序奏 NotificationBundle 實體消息」未在鏈配置的命名空間中找到我 DemoBundle 實體

學說配置

doctrine: 
    dbal: 
     default_connection: default  
     connections: 

      default: 
       driver: %database_driver% 
       host:  %database_host% 
       port:  %database_port% 
       dbname: %database_name% 
       user:  %database_user% 
       password: %database_password% 
       charset: UTF8 
       mapping_types: 
        enum: string 

      em1:      
       driver: %database_driver% 
       host:  %database_host% 
       port:  %database_port% 
       dbname: em1 
       user:  %database_user% 
       password: %database_password% 
       charset: UTF8 

      em2:      
       driver: %database_driver% 
       host:  %database_host% 
       port:  %database_port% 
       dbname: em2 
       user:  %database_user% 
       password: %database_password% 
       charset: UTF8 
     types: 
      json: Sonata\Doctrine\Types\JsonType 
orm: 
    auto_generate_proxy_classes: %kernel.debug% 
    default_entity_manager: default 

    entity_managers: 
     default: 
      connection: default 
      mappings: 
       MyDemoBundle : ~ 
       MyMessagingBundle : ~ 
     em1: 
      connection: em1 
      mappings: 
       MyOtherBundle : ~ 
     porting: 
      connection: em2 
      mappings: 
       SonataNotificationBundle: ~ 
       ApplicationSonataNotificationBundle: ~ 

我有MyDemoBundle中的所有實體

使用MyDemoBundle的實體,MyMessagingBundle正在從em1數據庫讀取表,創建消息以發送電子郵件並將這些消息傳遞給奏鳴曲後端服務,該服務應將其存儲到奏鳴曲的表'通知__message'在數據庫em2中。但我得到錯誤

類「應用\奏鳴曲\ NotificationBundle \實體\消息」鏈配置的命名空間我\ DemoBundle \實體

貌似叫SonataNotificationBundle的服務,這是EM2實體下沒有被發現來自MyMessagingBundle的經理,該經理在em1 enitiy manager下不允許sonata訪問em2下的實體。它試圖從服務被調用的地方找到實體。

最初,當下面的捆綁下,在em1下的一切工作正常。我只是把他們移到em2的entitiy經理。

SonataNotificationBundle:〜 ApplicationSonataNotificationBundle:〜

請幫助。

回答

0

我自己得到了解決,

我只是挖中SonataNotificationBundle代碼。

他們,

<services> 
    <service id="sonata.notification.entity_manager" alias="doctrine.orm.default_entity_manager" /> 

    <service id="sonata.notification.manager.message.default" class="Sonata\NotificationBundle\Entity\MessageManager"> 
     <argument type="service" id="sonata.notification.entity_manager" /> 
     <argument>%sonata.notification.message.class%</argument> 
    </service> 
</services> 

幾乎加上默認的實體管理器,以便移動SonataNotificationBundle下自定義實體管理器將無法正常工作。

要修復它,我在config.yml中創建了具有相同名稱的服務,並將自定義實體管理器傳遞給它。

services: 
    sonata.notification.entity_manager: 
     alias: doctrine.orm.em2_entity_manager 
0

我只是找到了一個更好的辦法來做到這一點使用您的app/config/config.yml

sonata_notification: 
    class: 
      message: MyDemoBundle\Entity\Message 
相關問題