简体   繁体   中英

Sonata User - Injecting securityContext into Admin class

Maybe dumb question but I used easyExtends to customize SonataUser and I'm trying to inject the security context into the Admin class.

But in my extension there is no service definition and I don't see it neither in vendors.

So the question is quite simple:

How to inject the securityContext in my extended SonataUser Admin's class ?

After weeks of search with no response at all on none of my questions,
I finally found a SonataAdmin service definition example.

Here is what looks like mine:

services:
    sonata.admin.user:
        class: Application\Sonata\UserBundle\Admin\Entity\UserAdmin
        tags:
            - {name: sonata.admin, manager_type: orm, group: user, label: users}
        arguments:
            - null
            - Application\Sonata\UserBundle\Entity\User
            - 'SonataAdminBundle:CRUD'
        calls:
            - [setTranslationDomain, [MyProjectBundle]]
            - [setUserManager, ['@fos_user.user_manager']]
            - [setSecurityContext, ['@security.context']]

Obviously setSecurityContext() have to be implemented into the admin class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM