Symfony 班级';应用程序\Sonata\NotificationBundle\Entity\Message';在链配置的命名空间My\DemoBundle\Entity中找不到

Symfony 班级';应用程序\Sonata\NotificationBundle\Entity\Message';在链配置的命名空间My\DemoBundle\Entity中找不到,symfony,doctrine-orm,Symfony,Doctrine Orm,我有下面的配置 条令结构 我的所有实体都在MyDemoBundle中 使用MyDemoBundle的实体,MyMessagingBundle从em1数据库读取表,创建消息以发送电子邮件,并将这些消息传递给sonata后端服务,sonata后端服务应将它们存储到数据库em2中的sonata表“notifications_umessage”。但我犯了一个错误 在链配置的命名空间My\DemoBundle\Entity中找不到类“Application\Sonata\NotificationBundl

我有下面的配置

条令结构 我的所有实体都在MyDemoBundle中

使用MyDemoBundle的实体,MyMessagingBundle从em1数据库读取表,创建消息以发送电子邮件,并将这些消息传递给sonata后端服务,sonata后端服务应将它们存储到数据库em2中的sonata表“notifications_umessage”。但我犯了一个错误

在链配置的命名空间My\DemoBundle\Entity中找不到类“Application\Sonata\NotificationBundle\Entity\Message”

从em1 enitiy manager下的MyMessagingBundle调用em2实体管理器下的SonataNotificationBundle服务时,似乎不允许sonata访问其em2下的实体。它尝试从调用服务的位置查找实体

最初,在em1下,一切正常。我只是把他们转移到em2实体经理那里

SonataNotificationBundle:~ ApplicationsAnotificationBundle:~


请帮忙。

我自己找到了解决办法

我刚刚钻研了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>

我刚刚找到了一个更好的方法,使用你的
app/config/config.yml

sonata_notification:
    class:
            message: MyDemoBundle\Entity\Message
services:
    sonata.notification.entity_manager:
        alias: doctrine.orm.em2_entity_manager
sonata_notification:
    class:
            message: MyDemoBundle\Entity\Message