Overriding permissions

Created on 14 August 2023, over 1 year ago

Drupal 9.5.10, Group 2.1.0

Problem/Motivation

I have a custom module that depends on Group and wish to finely define Group permissions in my custom module.

Steps to reproduce

Install an old version of the module e.g. 8.x and add some Groups as admin user 1. When you upgrade to 2.1.0 the Groups you have created cannot be seen in 'admin/group'.
When logged in as a user with the 'administrator' role, permissions need to be given, they are no longer present automatically.

I addressed this in my custom module by implementing hook_entity_type_build and creating a custom 'access' handler class (e.g. MyModuleGroupAccessControlHandler) that extends the out-of-the-box GroupAccessControlHandler class that comes with the Group module.

However, 'admin/group' reports "There are no groups yet." although Group content e.g. '/group/1' can be viewed etc. thanks to the GroupAccessResult returned by the custom access handler MyModuleGroupAccessControlHandler.

The src/Entity/Group.php entity class has an access handler specified in the annotation: GroupAccessControlHandler. However, there is no query_access handler or list_builder handler specified in the Group entity annotation.

How do I extend Group in my custom module so that views like that at admin/group are defined by my own code and not Group's? (and not the permissions UI either). Please note this Support Request is general to roles and users that I might subsequently define myself, it is not just about admin or user/1

💬 Support request
Status

Active

Version

2.1

Component

Code

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024