显示/隐藏一些菜单取决于Sonata管理员的身份。[英] show/hide some menus depend on the Sonata admin ROLE

本文是小编为大家收集整理的关于显示/隐藏一些菜单取决于Sonata管理员的身份。的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我正在使用Symfony2进行Web项目,并且我在管理面板上使用了Sonata Admin,每件事都很好,但是我想做的是,在Sonata Admin的仪表板菜单上,我需要显示一些隐藏的东西菜单依赖于管理员的角色,所以任何人都这样做还是知道该怎么做? 我尝试使用角色的配置

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

谢谢

推荐答案

我找到了解决方案,我只需要在config.yml上定义

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

本文地址:https://www.itbaoku.cn/post/2090740.html

问题描述

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

推荐答案

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 ]