Skip to content
Snippets Groups Projects
Commit 7e24b3fa authored by bkosborne's avatar bkosborne Committed by Brian Osborne
Browse files

Issue #3186574 by bkosborne, mark_fullmer: Add specific permissions for...

Issue #3186574 by bkosborne, mark_fullmer: Add specific permissions for managing styles and administering the module
parent 370ade3a
No related branches found
Tags 8.x-1.0-beta3
No related merge requests found
manage layout builder styles:
title: 'Manage layout builder styles'
description: 'Create, edit, and delete all layout builder styles.'
administer layout builder styles configuration:
title: 'Administer layout builder styles configuration'
......@@ -23,6 +23,24 @@ function layout_builder_styles_post_update_update_add_layout_restrictions() {
}
}
/**
* Add new 'administer layout builder styles' perm to roles.
*/
function layout_builder_styles_post_update_add_new_perms() {
// Grant our new permissions to any role with the
// 'administer site configuration' permission, which is what was
// previously used to control access to this module.
$roles = \Drupal::entityTypeManager()->getStorage('user_role')->loadMultiple();
foreach ($roles as $role) {
/** @var \Drupal\user\RoleInterface $role */
if ($role->hasPermission('administer site configuration')) {
$role->grantPermission('manage layout builder styles');
$role->grantPermission('administer layout builder styles configuration');
$role->save();
}
}
}
/**
* Add defaults for config if not already set.
*/
......
......@@ -4,4 +4,4 @@ layout_builder_styles.settings:
_form: '\Drupal\layout_builder_styles\Form\ModuleSettingsForm'
_title: 'Settings'
requirements:
_permission: 'administer site configuration'
_permission: 'administer layout builder styles configuration'
......@@ -25,7 +25,7 @@ use Drupal\layout_builder_styles\LayoutBuilderStyleInterface;
* }
* },
* config_prefix = "style",
* admin_permission = "administer site configuration",
* admin_permission = "manage layout builder styles",
* entity_keys = {
* "id" = "id",
* "label" = "label",
......
......@@ -71,7 +71,7 @@ class LayoutBuilderStyleRestrictionsTest extends BrowserTestBase {
$this->drupalLogin($this->drupalCreateUser([
'configure any layout',
'administer site configuration',
'manage layout builder styles',
'create and edit custom blocks',
]));
......@@ -151,7 +151,8 @@ class LayoutBuilderStyleRestrictionsTest extends BrowserTestBase {
$this->drupalLogin($this->drupalCreateUser([
'configure any layout',
'administer site configuration',
'manage layout builder styles',
'administer layout builder styles configuration',
'create and edit custom blocks',
]));
......
......@@ -70,7 +70,8 @@ class LayoutBuilderStyleTest extends BrowserTestBase {
$this->drupalLogin($this->drupalCreateUser([
'configure any layout',
'administer site configuration',
'manage layout builder styles',
'administer layout builder styles configuration',
]));
// Create styles for section.
......@@ -139,7 +140,8 @@ class LayoutBuilderStyleTest extends BrowserTestBase {
$this->drupalLogin($this->drupalCreateUser([
'configure any layout',
'administer site configuration',
'manage layout builder styles',
'administer layout builder styles configuration',
]));
// Create styles for blocks.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment