Search code examples
symfonyfosuserbundlesonata-adminsymfony-2.3symfony-sonata

show/hide some menus depend on the Sonata admin ROLE


I'm working on a web project using Symfony2 , and i used Sonata Admin for the admin Panel , every thing works fine but what i want to do is ,on the dashboard menus of sonata Admin , i need to show hide some menus depend on the admin ROLE , so did any one do this before or know how to do it ? i tryed to use the config of the roles but when i'm connecting with a ROlE diffrent of ROLE_SONATA_ADMIN the top menu dont show up ,

- { path: ^/admin, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN,ROLE_ADMIN_NEWS] }

thanks


Solution

  • i found the solution for this i need just to define the groups on the config.yml Like this

    dashboard:
        groups:
            Content:
                label: Content
                items:
                    - sonata.admin.pages
                    - sonata.admin.menus
                roles: [ ROLE_ADMIN_CONTENT, ROLE_SUPER_ADMIN ]