You are here

public function AutoEntityLabelPermisssionController::autoEntityLabelPermissions in Automatic Entity Label 8

Returns an array of auto_entitylabel permissions.

Return value

array Return array with permission.

File

src/AutoEntityLabelPermisssionController.php, line 47

Class

AutoEntityLabelPermisssionController
Provides dynamic permissions of the auto_entitylabel module.

Namespace

Drupal\auto_entitylabel

Code

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

    // Create a permission for each fieldable entity to manage
    // the entity labels.
    $permissions['administer ' . $entity_type_id . ' labels'] = [
      'title' => $this
        ->t('%entity_label: Administer Entity Labels', [
        '%entity_label' => $entity_type
          ->getLabel(),
      ]),
      'restrict access' => TRUE,
    ];
  }
  return $permissions;
}