I'm trying to setup and use SonataMediaBundle for use inside SonataAdminBundle. I read and follow every step in docs for SMB. When I run the command:
php app/console sonata:easy-extends:generate SonataMediaBundle
By default this create the Bundle in app/
folder so manually I move into src/
folder where it should be. Now every time I try to access to my application I get this error:
MappingException: The class 'Application\Sonata\UserBundle\Entity\User' was not found in the chain configured namespaces Sonata\MediaBundle\Entity
And I don't know why, I check everywhere looking for references and didn't found nothing. Can any help me to fix this or give me a clue?
After reads and try several things I found where the error was. In my doctrine config I have:
orm:
auto_generate_proxy_classes: "%kernel.debug%"
# auto_mapping: true
entity_managers:
default:
mappings:
ApplicationSonataMediaBundle: ~
SonataMediaBundle: ~
By removing the auto_mapping clause, I no longer register UserBundle in the doctrine’s mapping directories. Hence it cannot find your User entity. So solution was either uncomment the auto_mapping: true
from your config and comment the entity_manager.default.mappings
part, or explicitly specify your User bundle in the section. So I pick the first one and my code looks like this now:
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# entity_managers:
# default:
# mappings:
# ApplicationSonataMediaBundle: ~
# SonataMediaBundle: ~