class Permissions in Block Region Permissions 8
Provides dynamic permissions for the block region permissions module.
Hierarchy
- class \Drupal\block_region_permissions\Permissions implements ContainerInjectionInterface uses StringTranslationTrait
 
Expanded class hierarchy of Permissions
File
- src/
Permissions.php, line 13  
Namespace
Drupal\block_region_permissionsView source
class Permissions implements ContainerInjectionInterface {
  use StringTranslationTrait;
  /**
   * The entity manager.
   *
   * @var \Drupal\Core\Extension\ThemeHandlerInterface
   */
  protected $themeHandler;
  /**
   * Constructs a new Permissions instance.
   *
   * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
   *   The theme handler.
   */
  public function __construct(ThemeHandlerInterface $theme_handler) {
    $this->themeHandler = $theme_handler;
  }
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('theme_handler'));
  }
  /**
   * Get permissions.
   *
   * @return array
   *   Array of permissions.
   */
  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;
  }
}Members
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            Permissions:: | 
                  protected | property | The entity manager. | |
| 
            Permissions:: | 
                  public static | function | 
            Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: | 
                  |
| 
            Permissions:: | 
                  public | function | Get permissions. | |
| 
            Permissions:: | 
                  public | function | Constructs a new Permissions instance. | |
| 
            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. |