8. Roles Matrix

The Sonata\UserBundle\Form\Type\RolesMatrixType was built to show all roles in a matrix view.

Role matrix

Every admin has defined default roles like:

  • EDIT
  • LIST
  • CREATE
  • VIEW
  • DELETE
  • EXPORT
  • ALL

The roles matrix consists of two parts:

  1. one that shows the matrix with each admin and their permissions.
  2. another that shows the custom roles which are configured in config/packages/security.yaml and lists them as checkboxes (and shows their inherited roles).

Note

The user can just use roles which he is granted.

8.1. How to exclude an admin

You can set the show_in_roles_matrix option to false, like this:

  • YAML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    # config/services.yaml
    
    services:
        app.admin.post:
            class: App\Admin\PostAdmin
            arguments:
                - ~
                - App\Entity\Post
                - ~
            tags:
                -
                    name: sonata.admin
                    manager_type: orm
                    label: 'Post'
                    show_in_roles_matrix: false