简体   繁体   中英

Sonata admin Dashboard Block Roles

I created a custom dashboard block for one of the admin entities called STUDY, a list.

  • Security Handler: sonata.admin.security.handler.role
  • Roles are stored in the Database for the user. (Groups the user belongs to)

I wish to display this block only when the user has LIST role allowed for the Study admin entity.

my config.yml

dashboard: blocks: position: left type: nzgui.app.block.status, roles: [ROLE_SONTATA_ADMIN_STUDIES_LIST]

This however does not work, and the block is not shown even for the super admin user.

Looking at the template the roles is being checked using is_granted(role) code call in twig. While in sidebar, the role is being checked using item.extra('admin').isGranted('LIST') and works.

How can I solve this issue ?

OK, solved it rather silly. A typo in the ROLE_SONTATA_ADMIN_STUDIES_LIST, corrected it to ROLE_SONATA_ADMIN_STUDIES.

However, the for the admin user, still had to provide ROLE_ADMIN additionally.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM