class ThemePerm in Theme permission 8
Theme Permission.
@package Drupal\theme_permission
Hierarchy
- class \Drupal\theme_permission\ThemePerm implements ContainerInjectionInterface uses StringTranslationTrait
Expanded class hierarchy of ThemePerm
File
- src/
ThemePerm.php, line 17
Namespace
Drupal\theme_permissionView source
class ThemePerm implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandler
*/
protected $themeHandler;
/**
* ThemePerm constructor.
*
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* The theme handler service.
*/
public function __construct(ThemeHandlerInterface $theme_handler) {
$this->themeHandler = $theme_handler;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('theme_handler'));
}
/**
* Returns an array of permissions.
*
* @return array
* The permissions.
*/
public function dynamicPermissions() {
$perms = [];
$themes = $this->themeHandler
->listInfo();
foreach ($themes as $theme => $value) {
$type_params = [
'%themename' => $theme,
];
$perms += [
"administer themes {$theme}" => [
'title' => $this
->t('administer themes %themename', $type_params),
],
"uninstall themes {$theme}" => [
'title' => $this
->t('uninstall themes %themename', $type_params),
],
"Edit Administration theme" => [
'title' => $this
->t('Edit Administration theme'),
],
];
}
return $perms;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
ThemePerm:: |
protected | property | The theme handler. | |
ThemePerm:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
ThemePerm:: |
public | function | Returns an array of permissions. | |
ThemePerm:: |
public | function | ThemePerm constructor. |