I'm using Symfony 4 and I would like to show / hide my entities in the menu depending on the roles, but it's impossible.
For example, I tried to override the menu.html.twig of EasyAdmin file but it didn't work.
It only works if I modify a loop directly in the EasyAdmin library but it's bad practice.
If you want to override an EasyAdmin template, create a directory ./templates/easy_admin
and put your templates inside.
In your case, just create ./templates/easy_admin/menu.html.twig
and this will override the default menu
try the package alterphp/easyadmin-extension-bundle
it provides this functionality
https://packagist.org/packages/alterphp/easyadmin-extension-bundle
easy_admin:
menu:
- { label: 'Administrator', role: ROLE_SUPER_ADMIN } # Hidden if user is not granted ROLE_SUPER_ADMIN
- { label: 'App action', route: 'app_action', role: ROLE_ADMIN } # Hidden if user is not granted ROLE_ADMIN