Display exception after installing SonataMediaBundle

I am trying to configure and use SonataMediaBundle for use inside SonataAdminBundle. I read and follow each step in docs for SMB . When I run the command:

php app/console sonata:easy-extends:generate SonataMediaBundle

By default, the Bundle folder is created in the folder app/, so manually I go to the folder src/where it should be. Now every time I try to access my application, I get this error:

MappingException: class "Application \ Sonata \ UserBundle \ Entity \ User" was not found in the configured namespace chain Sonata \ MediaBundle \ Entity

And I do not know why, I check the search for links everywhere and did not find anything. Can someone help me fix this or give me the key?

+3
source share
3 answers

After reading and trying a few things, I discovered where there was an error. In my doctrine configuration, I have:

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
#   auto_mapping: true
    entity_managers:
        default:
            mappings:
                ApplicationSonataMediaBundle: ~
                SonataMediaBundle: ~

Having removed the auto_mapping clause, I no longer register the UserBundle in the doctrine description directories. Therefore, it cannot find your user object. Thus, the decision was either to uncomment auto_mapping: truefrom your configuration, or to comment on a part entity_manager.default.mappings, or explicitly indicate your User package in this section. So I choose the first one, and my code looks like this:

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    auto_mapping: true
#    entity_managers:
#        default:
#            mappings:
#                ApplicationSonataMediaBundle: ~
#                SonataMediaBundle: ~
+3
source

delete it again and run the following command php app/console sonata:easy-extends:generate --dest=src SonataMediaBundle... You forgot --dest=srcand just moving the files, you would not change all namespaces.

0

, :

doctrine:
    orm:
        auto_generate_proxy_classes: %kernel.debug%
        entity_managers:
            default:
                auto_mapping: true
                mappings:
                    ApplicationSonataMediaBundle: ~
                    SonataMediaBundle: ~

auto_mapping: true doctrine, orm, entity_managers, , doctrine, orm.

0

All Articles