You are here

public function RabbitHolePermissionGenerator::permissions in Rabbit Hole 8

Same name and namespace in other branches
  1. 2.x src/RabbitHolePermissionGenerator.php \Drupal\rabbit_hole\RabbitHolePermissionGenerator::permissions()

Return an array of per-entity rabbit hole permissions.

Return value

array An array of permissions.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 string reference to 'RabbitHolePermissionGenerator::permissions'
rabbit_hole.permissions.yml in ./rabbit_hole.permissions.yml
rabbit_hole.permissions.yml

File

src/RabbitHolePermissionGenerator.php, line 66

Class

RabbitHolePermissionGenerator
Generates permission for each supported entity type.

Namespace

Drupal\rabbit_hole

Code

public function permissions() {
  $permissions = [];
  foreach ($this->rhEntityPluginManager
    ->getDefinitions() as $def) {
    $entity_type = $this->entityTypeManager
      ->getStorage($def['entityType'])
      ->getEntityType();
    $permissions += [
      'rabbit hole administer ' . $def['entityType'] => [
        'title' => $this
          ->t('Administer Rabbit Hole settings for %entity_type', [
          '%entity_type' => $entity_type
            ->getLabel(),
        ]),
      ],
      'rabbit hole bypass ' . $def['entityType'] => [
        'title' => $this
          ->t('Bypass Rabbit Hole action for %entity_type', [
          '%entity_type' => $entity_type
            ->getLabel(),
        ]),
      ],
    ];
  }
  return $permissions;
}