6. Roles Matrix
The Sonata\UserBundle\Form\Type\RolesMatrixType was built to show all
roles in a matrix view.
Every admin has defined default roles like:
EDIT
LIST
CREATE
VIEW
DELETE
EXPORT
ALL
The roles matrix consists of two parts:
one that shows the matrix with each admin and their permissions.
another that shows the custom roles which are configured in
config/packages/security.yamland lists them as checkboxes (and shows their inherited roles).
Note
The user can just use roles which he is granted.
6.1. How to exclude an admin
You can set the show_in_roles_matrix option to false, like this:
# config/services.yaml
services:
app.admin.post:
class: App\Admin\PostAdmin
tags:
-
name: sonata.admin
model_class: App\Entity\Post
manager_type: orm
label: 'Post'
show_in_roles_matrix: false
6.2. How to exclude roles
When using the Form Type, you can use excluded_roles to not show them in the matrix.
By default, only UserInterface::ROLE_DEFAULT aka ROLE_USER is not shown.