EasyAdminBundle - 按角色和组划分的用户列表

EasyAdminBundle - List of users by role and group

我正在尝试使用 EasyAdminBundle (https://github.com/EasyCorp/EasyAdminBundle) 来管理我项目的管理部分。

我目前正在做用户列表,效果很好。我得到了所有现有用户的列表

但是,用户都是分组分配的,在这些组中有 "supervisors"。我想做的是,这些 "ROLE_SUPERVISOR" 可以访问用户管理页面,但他们只能看到同一组的用户。

总结一下我想要的: - 我 (ROLE_SUPER_ADMIN):我想查看所有现有用户 - ROLE_SUPERVISOR:查看与他们同组的所有用户。

这可能吗?

我的 EasyAdminBundle 配置文件:

easy_admin:
  site_name: '<img height="65px" src="../img/logo.png" />'
  user:
    display_name: true
    name_property_path: 'username'
    display_avatar: false
  design:
    brand_color: '#7C1AE8'
    menu:
      - { entity: 'User', css_class: 'menu--user', icon: 'user', role: [ROLE_SUPERVISEUR, ROLE_SUPER_ADMIN] }
  entities:
    User:
      class: App\Entity\User
      label: 'Utilisateurs'
      list:
        title: "Liste des utilisateurs"
        fields:
          - email
          - { property: 'username', label: "Nom d'utilisateur" }
          - { property: 'group.name', label: "Groupe" }
          - { property: 'lastLogin', label: "Dernière connexion", format: 'd/m/Y H:i:s', type: 'datetime' }
        sort: 'group.name'

item_permission 个:

easy_admin:
    ...
    entities:
        Product:
            list:
                # set this option to an empty string or array to unset the global permission for this entity
                item_permission: ''
        Employees:
            list:
                # this completely overrides the global option (both options are not merged)
                item_permission: ['ROLE_SUPER_ADMIN', 'ROLE_HUMAN_RESOURCES']

查看文档 https://symfony.com/doc/master/bundles/EasyAdminBundle/book/list-search-show-configuration.html#security-and-permissions