Sonata admin,不使用FOSUserBundle的全局访问权限

时间:2013-12-12 20:56:31

标签: php symfony sonata-admin

我想拥有它,所以我可以在symfony2中定义每个角色的动作

这就是我目前所拥有的

role_hierarchy:
        ROLE_MEMBER: ROLE_GUEST
        ROLE_STAFF: ROLE_MEMBER
        ROLE_ADMIN: [ROLE_STAFF, ROLE_SONATA_OWNER, ADMIN, OWNER]

sonata_admin:
    #title_logo: bundles/acmedemo/img/fancy_acme_logo.png
    security:
        handler: sonata.admin.security.handler.acl
        # acl security information
        information:
            GUEST:    []
            STAFF:    [EDIT, LIST, CREATE]
            EDITOR:   [OPERATOR, EXPORT]
            ADMIN:    [MASTER]
            OWNER:    [OWNER]
        # permissions not related to an object instance and also to be available when objects do not exist
        # the DELETE admin permission means the user is allowed to batch delete objects
        admin_permissions: [CREATE, LIST, DELETE, UNDELETE, EXPORT, OPERATOR, MASTER]
        # permission related to the objects
        object_permissions: [VIEW, EDIT, DELETE, UNDELETE, OPERATOR, MASTER, OWNER]

我正在寻找让我能够授予ROLE_ADMIN SONATA ROLE OWNER的东西,例如,我真的不知道如何做到这一点,并且奏鸣曲文档更适合我不使用的FOSUserBundle。

任何帮助表示赞赏

1 个答案:

答案 0 :(得分:0)

如果您只想向已经拥有ROLE_SONATA_OWNER的所有用户授予ROLE_ADMIN,您可以通过修改角色层次结构(参见the Symfony2 docs'“层次角色”部分)来实现此目的:

role_hierarchy:
    ROLE_MEMBER:       ROLE_GUEST
    ROLE_STAFF:        ROLE_MEMBER
    ROLE_ADMIN:       [ROLE_STAFF, ADMIN, OWNER]
    ROLE_SONATA_OWNER: ROLE_ADMIN