You are here

public function AutoEntityLabelPermissionController::autoEntityLabelPermissions in Automatic Entity Label 8.3

Same name and namespace in other branches
  1. 8 src/AutoEntityLabelPermissionController.php \Drupal\auto_entitylabel\AutoEntityLabelPermissionController::autoEntityLabelPermissions()
  2. 8.2 src/AutoEntityLabelPermissionController.php \Drupal\auto_entitylabel\AutoEntityLabelPermissionController::autoEntityLabelPermissions()

Returns an array of auto_entitylabel permissions.

Return value

array Array with permissions.

1 string reference to 'AutoEntityLabelPermissionController::autoEntityLabelPermissions'
auto_entitylabel.permissions.yml in ./auto_entitylabel.permissions.yml
auto_entitylabel.permissions.yml

File

src/AutoEntityLabelPermissionController.php, line 47

Class

AutoEntityLabelPermissionController
Provides dynamic permissions of the auto_entitylabel module.

Namespace

Drupal\auto_entitylabel

Code

public function autoEntityLabelPermissions() {
  $permissions = [];
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entity_type_id => $entity_type) {

    // Create a permission for each entity type to manage the entity
    // labels.
    if ($entity_type
      ->hasLinkTemplate('auto-label') && $entity_type
      ->hasKey('label')) {
      $permissions['administer ' . $entity_type_id . ' labels'] = [
        'title' => $this
          ->t('%entity_label: Administer automatic entity labels', [
          '%entity_label' => $entity_type
            ->getLabel(),
        ]),
        'restrict access' => TRUE,
      ];
    }
  }
  return $permissions;
}