public function BlockPermissionsPermissions::permissions in Block permissions 8
Return the permissions for the block permissions.
Return value
array Array of permissions.
1 string reference to 'BlockPermissionsPermissions::permissions'
File
- src/
BlockPermissionsPermissions.php, line 61
Class
- BlockPermissionsPermissions
- Provides dynamic permissions of the blocks module.
Namespace
Drupal\block_permissionsCode
public function permissions() {
$permissions = [];
// Get a list of available themes and generate a permission for block
// administration per theme.
$themes = $this->themeHandler
->listInfo();
foreach ($themes as $key => $theme) {
if ($theme->status == 1 && (!isset($theme->info['hidden']) || $theme->info['hidden'] != 1)) {
$permissions['administer block settings for theme ' . $key] = [
'title' => $this
->t('Administer block settings for the theme @label', [
'@label' => ucfirst($theme
->getName()),
]),
'description' => $this
->t('This permission refines the administer blocks permission.'),
];
}
}
// Create a permission for each block category.
$definitions = $this->blockManager
->getDefinitions();
$providers = [];
foreach ($definitions as $definition) {
$providers[$definition['provider']] = $definition['provider'];
}
foreach ($providers as $provider) {
$permissions['administer blocks provided by ' . $provider] = [
'title' => $this
->t('Manage blocks provided by @label', [
'@label' => $provider,
]),
'description' => $this
->t('When not given, the user cannot manage blocks provided by this provider.'),
];
}
return $permissions;
}