Permissions.php in Block Region Permissions 8
File
src/Permissions.php
View source
<?php
namespace Drupal\block_region_permissions;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
class Permissions implements ContainerInjectionInterface {
use StringTranslationTrait;
protected $themeHandler;
public function __construct(ThemeHandlerInterface $theme_handler) {
$this->themeHandler = $theme_handler;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('theme_handler'));
}
public function get() {
$permissions = [];
$themes = $this->themeHandler
->listInfo();
foreach ($themes as $theme_key => $theme) {
if ($theme->status == 1 && (!isset($theme->info['hidden']) || $theme->info['hidden'] != 1)) {
$theme_name = $theme->info['name'];
$regions = $theme->info['regions'];
foreach ($regions as $region_key => $region_name) {
$permissions["administer {$theme_key} {$region_key}"] = [
'title' => $this
->t('Administer: <em>@theme</em> - <em>@region</em>', [
'@theme' => $theme_name,
'@region' => $region_name,
]),
];
}
}
}
return $permissions;
}
}
Classes
Name |
Description |
Permissions |
Provides dynamic permissions for the block region permissions module. |