简体   繁体   English

如何过滤每个用户的Symfony easyadmin菜单?

[英]How to filter Symfony easyadmin Menu per user?

I have a simple menu that looks like the following 我有一个简单的菜单,如下所示

easy_admin:
design:
    menu:
        - { entity: 'Entity2',icon: 'database' }
        - { entity: 'Entity3',icon: 'sitemap' }
        - { entity: 'Entity4',icon: 'window-restore'}
        - { entity: 'Entity5', icon: 'pencil'  }
        - { entity: 'Entity6',icon: 'address-book' }
        - { entity: 'Entity7',icon: 'cog' }
        - { entity: 'Entity8',icon: 'child' }

what i want to do is to show each menu item according to the logged in username, for example Entity2 to appear only if the logged in username is "admin". 我想要做的是根据登录的用户名显示每个菜单项,例如,仅当登录的用户名是“ admin”时才显示Entity2。

also how to write if statement in .yml files ?! 还如何在.yml文件中编写if语句?

Thanks in Advance. 提前致谢。

You can't write if in .yml files. 如果是.yml文件,则无法写入。 There is no easy solution for this problem. 没有解决此问题的简便方法。

You could implement the solution given by javiereguiluz and rubengc in this github issue : https://github.com/javiereguiluz/EasyAdminBundle/issues/831 . 您可以在此github问题中实现javiereguiluz和rubengc给出的解决方案: https : //github.com/javiereguiluz/EasyAdminBundle/issues/831

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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