简体   繁体   English

在Sonata Admin中编辑列表视图(角色/权限)

[英]Edit in list view (role/permissions) in Sonata Admin

I'm looking for a solutions where I can do the following in my Sonata backend: 我正在寻找一个解决方案,我可以在我的Sonata后端执行以下操作:

在此输入图像描述

In my database I have the following tables: 在我的数据库中,我有以下表格:

  • roles 角色
    • id ID
    • name 名称
    • role 角色
    • is_super_admin is_super_admin
    • weight 重量
  • permissions 权限
    • name 名称
    • permissions 权限
    • description 描述
  • role_permission (many to many) role_permission (多对多)
    • role_id ROLE_ID
    • permission_id permission_id

So I would like to save relations in my table role_permission . 所以我想在我的表role_permission中保存关系。 But I'm a bit stuck on how to do this in Sonata admin. 但是我在Sonata admin中有点坚持如何做到这一点。 Can I do this in the list view? 我可以在列表视图中执行此操作吗? And if yes, can you help me on my way? 如果是的话,你可以帮助我吗?

Not sure if OP wants to implement custom roles or use existing features. 不确定OP是否要实现自定义角色或使用现有功能。 However I would recommend using a single role system. 但是,我建议使用单一角色系统。 Sonata already has handlers for security so in my opinion it would be best to use those instead of creating your own. Sonata已经拥有安全处理程序,所以我认为最好使用它们而不是创建自己的。

On the sonata site, there is a section in the admin bundle about security . 在奏鸣曲网站上, 管理包中一节关于安全性 Which explains how to setup certain types of role management. 其中介绍了如何设置某些类型的角色管理。 I would either go for the Role or ACL handler depending on what you need. 我会根据你的需要选择角色或ACL处理程序。

When enabling the role handler you can create groups of roles. 启用角色处理程序时,您可以创建角色组。 These groups would serve as your "Role 1". 这些组将作为您的“角色1”。 For example I could create a group called "Beta Testers" and give them the ROLES (permissions) ROLE_CHECK_BETA_CONTENT and ROLE_BETA_FEEDBACK_FORM . 例如,我可以创建一个名为“Beta Testers”的组,并ROLE_BETA_FEEDBACK_FORM提供ROLES(权限) ROLE_CHECK_BETA_CONTENTROLE_BETA_FEEDBACK_FORM Now if you want normal users to not have these rights you could create a normal user group and assign every other role (permission). 现在,如果您希望普通用户没有这些权限,您可以创建普通用户组并分配所有其他角色(权限)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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