Skip to content
Snippets Groups Projects
Commit bd5da5da authored by Marcos Hollanda's avatar Marcos Hollanda
Browse files

Issue #3479462 by mabho: Create a new permission to limit the user roles that can see the debugger

parent e8a51e6c
No related branches found
No related tags found
1 merge request!18Create a new permission to limit the user roles that can see the Visual Debugger panel.
......@@ -53,13 +53,21 @@ function visual_debugger_page_attachments(array &$attachments): void {
$use_on_frontend = $config->get(VisualDebuggerConstants::IS_FRONTEND_KEY);
$use_on_admin = $config->get(VisualDebuggerConstants::IS_ADMIN_KEY);
// Checking one of these possibilities:
// Get the current user service.
$current_user = \Drupal::currentUser();
$has_permission = $current_user->hasPermission('view visual_debugger panel');
// Validates if user has permission to view the Visual Debugger panel, and
// checks for one of these possibilities:
// - This is an Admin page, and debugger is activated for admin theme.
// - This is a frontend page, and debugger is activated for frontend theme.
if (
$has_permission &&
(
($is_admin_theme && $use_on_admin)
||
(!$is_admin_theme && $use_on_frontend)
)
) {
// Attach the library.
$attachments['#attached']['library'][] = 'visual_debugger/visual_debugger';
......
administer visual_debugger configuration:
title: "Administer visual_debugger configuration"
description: "Optional description."
restrict access: true
title: "Administer the Visual Debugger configuration"
restrict access: false
view visual_debugger panel:
title: "View the Visual Debugger panel"
restrict access: false
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment