Problem/Motivation
Currently, the Entity Usage Explorer overview page does not have a dedicated permission.
Access to this page cannot be controlled role-wise, which means site administrators cannot restrict or grant access to specific roles.
Steps to reproduce
1. Enable the Entity Usage Explorer module.
2. Log in as a user with a role that does not have the `administer content` permission.
3. Try visiting `/admin/usage/{entity_type}/{entity_id}`.
- The page is not accessible, since only users with the `administer content` permission can currently view it.
4. Go to `/admin/people/permissions`.
- There is no dedicated permission available to grant role-specific access to the Entity Usage overview page.
Proposed resolution
- Add a custom permission: Access Entity Usage overview page.
- Apply this permission to the route `entity_usage_explorer.usage_page`.
- Update `hook_entity_operation()` so that the “Usage” operation link is only shown if the current user has this permission.
- This will allow site administrators to grant or deny access role-wise.
Remaining tasks
- Add the new permission in `entity_usage_explorer.permissions.yml`.
- Update the route definition to require the new permission.
- Update `hook_entity_operation()` to check the permission via `$account->hasPermission()`.
- Test with different roles to ensure the link only appears when permission is granted.
- Add/update automated tests if available.
User interface changes
- A new permission “Access Entity Usage overview page” will appear on the `/admin/people/permissions` page.
- Site admins can assign or revoke this permission per role.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | after_patch_page_access.png | 351.65 KB | ambuj_gupta |
| #5 | after_patch_permission_set.png | 354.99 KB | ambuj_gupta |
| #5 | after_patch_permission.png | 367.62 KB | ambuj_gupta |
| #5 | before_patch.png | 298.27 KB | ambuj_gupta |
Issue fork entity_usage_explorer-3543481
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
keshav patel commentedComment #4
ambuj_gupta commentedComment #5
ambuj_gupta commentedTested and Reviewed
Testing Results:
Before Patch:
After Patch:
Everything works as expected after applying the patch. Marking this as Reviewed & Tested by the Community.
Comment #6
ambuj_gupta commentedComment #7
ambuj_gupta commentedComment #9
keshav patel commentedThanks for a thorough review @ambuj_gupta.
Merging it into branch 1.0.x, release forthcoming.
Comment #10
keshav patel commentedAdded release and updated the project description along with screenshot.
Thanks!