1
votes

I try to use sonata admin bundle and sonata bundle. I have created the ApplicationSontaUserBundle and everything works fine if I use fosUserInterface. But i have another user Bundle, named Sso for example. So in my app i need to use Sso userManger instead of FosUserManager. The sonata user bundle contains a "admin_orm.xml", and in this services configuration file, I have this line in file:(in sonata user bundle)

   <service id="sonata.user.admin.user" class="%sonata.user.admin.user.class%">
        <tag name="sonata.admin" manager_type="orm" label="users" label_catalogue="SonataUserBundle" label_translator_strategy="sonata.admin.label.strategy.underscore" />
        <argument />
        <argument>%sonata.user.admin.user.entity%</argument>
        <argument>%sonata.user.admin.user.controller%</argument>
        <call method="setUserManager">
            <argument type="service" id="fos_user.user_manager" />
        </call>
        <call method="setTranslationDomain">
            <argument>%sonata.user.admin.user.translation_domain%</argument>
        </call>
    </service>

And in Application/Sonata/UserBundle/Resources/config/admin_orm.xml, I have this one:

        <call method="setUserManager">
            <argument type="service" id="sso.user_manager" />
        </call>

Because i defined another userAdmin in Application/Sonata/Admin/Model/UserAdmin.php

use xxx\SsoBundle\Entity\UserManager;
....
/**
 * @param UserManager $userManager
 */
public function setUserManager(UserManager $userManager)
{
    $this->userManager = $userManager;
}

Instead of the original FosUserInterface. But, it never take my settings in

 Application/Sonata/UserBundle/Resources/config/admin_orm.xml

It always complain the user manager is a FosUserInterface object and I need my own user manager. If i change the

/vendor/sonata-project/user-bundle/Sonata/UserBundle/Resources/config/admin_orm.xml

and set my own user manager, everything works fine. Anyone can tell me how to override this file?

1

1 Answers

1
votes

well, after 2 years, I found the solution. And it is so stupid. I need to define the dependencyInjection class to load the xml and the service will be loaded. The child bundle's configuration file will not be loaded if u do not write the dependencyInjection class. Just as a normal bundle. The configuration file can not be "overwrite", every bundle's configuration file will be red and the last one will win.