The documentation for the SonataAdminBundle mentions how to expose services inside your Admin class using XML:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<service id="sonata.news.admin.post" class="%sonata.news.admin.post.class%"> | |
<tag name="sonata.admin" manager_type="orm" group="sonata_blog" label="post"/> | |
<argument /> | |
<argument>%sonata.news.admin.post.entity%</argument> | |
<argument>%sonata.news.admin.post.controller%</argument> | |
<call method="setUserManager"> | |
<argument type="service" id="fos_user.user_manager" /> | |
</call> | |
</service> |
But unfortunately it doesn’t detail how to do it YAML. Turns out its pretty straightforward, the “gotcha” of course being you need to add the “@” to indicate a service:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ct.be.admin.users: | |
class: CT\BEBundle\Admin\UserAdmin | |
tags: | |
- { name: sonata.admin, manager_type: orm, group: Manage User Settings, label: Users } | |
arguments: [null, CT\BEBundle\Entity\User, "SonataAdminBundle:CRUD"] | |
calls: | |
- [setUserManager, [@fos_user.user_manager]] |