使用SonataCommentBundle的Symfony2 MappingException

时间:2014-08-28 09:18:16

标签: symfony foscommentbundle

在集成此捆绑包后,我使用SonataCommentBundle版本~2.2@dev 我试着http://xx.out.tn/app_dev.php/comments/threads它给了我:

The class 'Application\Sonata\CommentBundle\Entity\Thread' was not found in the chain configured namespaces Application\Sonata\PageBundle\Entity, Sonata\PageBundle\Entity, Application\Sonata\MediaBundle\Entity, Sonata\MediaBundle\Entity, FOS\UserBundle\Entity, Application\Sonata\UserBundle\Entity, Sonata\UserBundle\Entity, Sonata\NotificationBundle\Entity, Application\Sonata\NotificationBundle\Entity, FOS\CommentBundle\Entity, Sonata\CommentBundle\Entity, Sonata\ClassificationBundle\Entity, Application\Sonata\ClassificationBundle\Entity, Spy\TimelineBundle\Entity, Application\Sonata\TimelineBundle\Entity, Sonata\Bundle\DemoBundle\Entity, Sonata\TimelineBundle\Entity

我的config.yml:

fos_comment:
    db_driver: orm

    class:
        model:
            comment: Application\Sonata\CommentBundle\Entity\Comment
            thread:  Application\Sonata\CommentBundle\Entity\Thread
    form:
        comment:
            type: sonata_comment_comment

assetic:
    bundles: [ "FOSCommentBundle" ] 

routing.yml:

fos_comment:
    type: rest
    resource: "@FOSCommentBundle/Resources/config/routing.yml"
    prefix: /comments
    defaults: { _format: html }

1 个答案:

答案 0 :(得分:0)

解决方案是添加Application Sonata Comment Bundle而不是Sonata CommentBundle SonataCommentBundle

这个

new Application\Sonata\CommentBundle\ApplicationSonataCommentBundle()

而不是

new Sonata\CommentBundle\SonataCommentBundle()