我尝试按照此指南https://sonata-project.org/bundles/media/3-x/doc/reference/installation.html将Sonata Media Bundle安装到Symfony CMF中。这个命令

php app/console sonata:easy-extends:generate --dest=src SonataMediaBundle

用几个实体制作一个全新的捆绑包ApplicationSonataMediaBundle:
  • 画廊
  • GalleryHasMedia
  • 媒体

  • 但是当我想转到下一步时,我得到一个错误,即实体类别不存在:
    app/console doctrine:schema:update --force
    

    这是完整的错误:
    [Doctrine\ORM\Mapping\MappingException]
      The target-entity Application\Sonata\ClassificationBundle\Entity\Category cannot be found in 'Application\Sonata\MediaBundle\Entity\Med
      ia#category'.
    

    有没有人可以帮助我解决这个问题?

    提前致谢。

    更新:
    # sonata_classification.yml:
    
    sonata_classification:
        # ...
    
    doctrine:
        orm:
            entity_managers:
                default:
                    #metadata_cache_driver: apc
                    #query_cache_driver: apc
                    #result_cache_driver: apc
                    mappings:
                        #ApplicationSonataClassificationBundle: ~
                        SonataClassificationBundle: ~
    

    最佳答案

    我必须设置此配置选项才能使其正常工作:

    sonata_media:
        class:
            media: Application\MediaBundle\Entity\Media
            gallery: Application\MediaBundle\Entity\Gallery
            gallery_has_media: Application\MediaBundle\Entity\GalleryHasMedia
        # ...
    

    并且:
    doctrine_phpcr:
        # ...
    
        odm:
            auto_mapping: true
            mappings:
                SonataMediaBundle:
                    prefix: Sonata\MediaBundle\PHPCR
                ApplicationSonataMediaBundle:
                    prefix: Application\Sonata\MediaBundle\PHPCR
    

    关于symfony - Sonata Media Bundle缺少实体类别,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38568753/

    10-14 15:08