Reputation: 2478
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?
Upvotes: 3
Views: 2796
Reputation: 2049
I found solution where it should be:
doctrine:
orm:
auto_generate_proxy_classes: %kernel.debug%
entity_managers:
default:
auto_mapping: true
mappings:
ApplicationSonataMediaBundle: ~
SonataMediaBundle: ~
auto_mapping: true must be into doctrine, orm, entity_managers, default section and not into doctrine, orm.
Upvotes: 0
Reputation: 2478
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: ~
Upvotes: 3
Reputation: 1654
remove it again and run following command, php app/console sonata:easy-extends:generate --dest=src SonataMediaBundle
... You forgot the --dest=src
and just by moving the files you won't have changed all the namespaces.
Upvotes: 0