Roles in Sonata Admin

风流意气都作罢 提交于 2019-12-11 04:28:17

问题


Good day. I can not understand how in sonata admin bundle to add roles to users. Namely, it is necessary that the user with a specific role seen in adminpanel only one entity and only worked with her. For now, there is only one role - it ROLE_SONATA_ADMIN, which gives access to the whole adminpanel. On official site found just such an example :

security:
    ...
    role_hierarchy:
        # for convenience, I decided to gather Sonata roles here
        ROLE_SONATA_FOO_READER:
            - ROLE_SONATA_ADMIN_DEMO_FOO_LIST
            - ROLE_SONATA_ADMIN_DEMO_FOO_VIEW
        ROLE_SONATA_FOO_EDITOR:
            - ROLE_SONATA_ADMIN_DEMO_FOO_CREATE
            - ROLE_SONATA_ADMIN_DEMO_FOO_EDIT
        ROLE_SONATA_FOO_ADMIN:
            - ROLE_SONATA_ADMIN_DEMO_FOO_DELETE
            - ROLE_SONATA_ADMIN_DEMO_FOO_EXPORT
        # those are the roles I will use (less verbose)
        ROLE_STAFF:             [ROLE_USER, ROLE_SONATA_FOO_READER]
        ROLE_ADMIN:             [ROLE_STAFF, ROLE_SONATA_FOO_EDITOR, ROLE_SONATA_FOO_ADMIN]
        ROLE_SUPER_ADMIN:       [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

But I can not understand that instead embed DEMO, and that instead of FOO. Tried a lot of options but nothing is worked.

Thanks in advance and sorry for my bad English.


回答1:


The permissions are:

  • LIST: view the list of objects
  • VIEW: view the detail of one object
  • CREATE: create a new object
  • EDIT: update an existing object
  • DELETE: delete an existing object
  • EXPORT (for the native Sonata export links)


来源:https://stackoverflow.com/questions/22380625/roles-in-sonata-admin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!