I want to set up my own Permission in Sonata Admin Bundle but I read the documentation and I am confused. I can add the standard permission to roles but What I want to do is create my own permission "PUSH" that means if a user can create PUSH notification.
I am following the instructions given in Official Documentation but I am not able to do it. For sure that I am misunderstanding something because I think that is something really normal to do.
More in detail. We have these permissions and I want to add another permission here.
Permission Description
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)
ALL grants LIST, VIEW, CREATE, EDIT, DELETE and EXPORT
My configuration is:
security:
handler: sonata.admin.security.handler.acl
information:
PUSH: [LIST, PUSH]
GUEST: [VIEW, LIST]
STAFF: [EDIT, LIST, CREATE, PUSH]
EDITOR: [OPERATOR, EXPORT]
ADMIN: [MASTER]
admin_permissions: [VIEW, CREATE, LIST, DELETE, UNDELETE, PUSH, EXPORT, OPERATOR, MASTER]
But when I execute this command to setup the new command is not working
php app/console sonata:admin:setup-acl
I get this error:
[InvalidArgumentException]
The code "PUSH" is not supported
Any Ideas? Maybe is not possible to do what I want.
I don't find how to solve it what I want but I did a work around.
The Idea is that I create a new Role (PUSH_ROLE) and then I assigned this Role to the users that I want. Then in the twig template I check if is_granted('ROLE_PUSH') is True.
How to create a New role:
sonata_admin:
security:
handler: sonata.admin.security.handler.acl
role_admin: ROLE_ADMIN
role_super_admin: ROLE_SUPER_ADMIN
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.