I try to install the Sonata Media Bundle into the Symfony CMF following this guide: https://sonata-project.org/bundles/media/3-x/doc/reference/installation.html. This command
php app/console sonata:easy-extends:generate --dest=src SonataMediaBundle
makes a whole new bundle ApplicationSonataMediaBundle
with a few entities:
But i get the error that the entity Category does not exist when i want to go to the next step:
app/console doctrine:schema:update --force
This is the complete error:
[Doctrine\ORM\Mapping\MappingException]
The target-entity Application\Sonata\ClassificationBundle\Entity\Category cannot be found in 'Application\Sonata\MediaBundle\Entity\Med
ia#category'.
Is there somebody who can help me to solve this?
Thanks in advance.
Update:
# 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: ~
I had to set this configuration options to get it to work:
sonata_media:
class:
media: Application\MediaBundle\Entity\Media
gallery: Application\MediaBundle\Entity\Gallery
gallery_has_media: Application\MediaBundle\Entity\GalleryHasMedia
# ...
And also:
doctrine_phpcr:
# ...
odm:
auto_mapping: true
mappings:
SonataMediaBundle:
prefix: Sonata\MediaBundle\PHPCR
ApplicationSonataMediaBundle:
prefix: Application\Sonata\MediaBundle\PHPCR
I had the same problem after installing news bundle (which brings classification and media bundles with it). I configured both media and classification before news and received the same error as OP. After looking into the code I noticed that media bundle allows for another class to be specified for category. This stopped the error for me.
sonata_media:
class:
# my own bundle namespaces for media and classification bundles
media: Application\Sonata\MediaBundle\Entity\Media
gallery: Application\Sonata\MediaBundle\Entity\Gallery
gallery_has_media: Application\Sonata\MediaBundle\Entity\GalleryHasMedia
category: Application\Sonata\ClassificationBundle\Entity\Category
Looks like you just need to create a sonata_classification.yml file as described in the classification docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With