Search code examples
phpsymfonypermissionsyamlsymfony2-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".

also how to write if statement in .yml files ?!

Thanks in Advance.


Solution

  • You can't write if in .yml files. 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.