You are here

public function Permissions::get in Block Region Permissions 8

Get permissions.

Return value

array Array of permissions.

1 string reference to 'Permissions::get'
block_region_permissions.permissions.yml in ./block_region_permissions.permissions.yml
block_region_permissions.permissions.yml

File

src/Permissions.php, line 49

Class

Permissions
Provides dynamic permissions for the block region permissions module.

Namespace

Drupal\block_region_permissions

Code

public function get() {
  $permissions = [];

  // Get themes and generate permissions for each theme's regions.
  $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'];

      // Get regions for this theme.
      $regions = $theme->info['regions'];

      // Add permissions for each region.
      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;
}