phpsymfonysecuritysonata-adminsymfony-sonata

I need to add new custom ROLE in a symfony 2 to manage the permission in the SONATA Bundle


I need to create a new ROLE as ROLE_ERECTA_TASK_ADMIN but I don't know how, where I must to declare to se it in a Sonata admin interface? I use Sonata Bundle to manage my User Group Role, now I have only some ROLES but I want to create some other form my Bundles.

My security.yml

role_hierarchy:
        ROLE_ADMIN:       [ROLE_USER, ROLE_SONATA_ADMIN]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
        # PROTEZIONE MODULO TASK
        ROLE_ERECTA_TASK_ADMIN: [ROLE_ERECTA_TASK_USER]
        ROLE_ERECTA_TASK_SA: [ROLE_ERECTA_TASK_ADMIN, ROLE_ALLOWED_TO_SWITCH]
        SONATA:
            - ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT  # if you are using acl then this line must be commented

Sonata Admin User manager: enter image description here

Thanks in advance.


Solution

  • There is another quick workaround to add roles. Just edit security.yml and add roles to ROLE_SUPER_ADMIN.

    role_hierarchy:
        ...
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH, ROLE_FOO, ROLE_BAR, ...]