You are here

public function ThemePerm::dynamicPermissions in Theme permission 8

Returns an array of permissions.

Return value

array The permissions.

1 string reference to 'ThemePerm::dynamicPermissions'
theme_permission.permissions.yml in ./theme_permission.permissions.yml
theme_permission.permissions.yml

File

src/ThemePerm.php, line 53

Class

ThemePerm
Theme Permission.

Namespace

Drupal\theme_permission

Code

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;
}