phpsymfonysonata-adminsymfony-sonatasonata-user-bundle

Display items on dashboard according to user role


I'm new to Symfony2, and for the needs of my company I'm using Sonata Admin and User bundles.

I would like to know if it is possible to hide or show items on the dashboard according to the role of a logged user.

For example, I have several entities which are managed by Sonata AdminBundle (user, company, mission, site, etc ... management) and I want to display the user management only to the super Admin, company and site management to another role (SITE_ADMIN for example) and missions to a third role.

Have you ever faced this situation ? Could you give me the solution or clues to go directly to the solution ?

Many thanks,

Enes


Solution

  • Use Role handler and enable User related rights only to, for example, Admins group (create it). Then assign admin users to Admins group. Sonata Admin will pick up restrictions and will only display dashboard items to Admins.