public function AutoEntityLabelPermissionController::autoEntityLabelPermissions in Automatic Entity Label 8
Same name and namespace in other branches
- 8.3 src/AutoEntityLabelPermissionController.php \Drupal\auto_entitylabel\AutoEntityLabelPermissionController::autoEntityLabelPermissions()
- 8.2 src/AutoEntityLabelPermissionController.php \Drupal\auto_entitylabel\AutoEntityLabelPermissionController::autoEntityLabelPermissions()
Returns an array of auto_entitylabel permissions.
Return value
array Return array with permissions.
1 string reference to 'AutoEntityLabelPermissionController::autoEntityLabelPermissions'
File
- src/
AutoEntityLabelPermissionController.php, line 47
Class
- AutoEntityLabelPermissionController
- Provides dynamic permissions of the auto_entitylabel module.
Namespace
Drupal\auto_entitylabelCode
public function autoEntityLabelPermissions() {
$permissions = [];
foreach ($this->entityManager
->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,
];
}
}
// Create permission to use PHP in entity label patterns.
$permissions['use PHP for auto entity labels'] = [
'title' => $this
->t('Use PHP for automatic entity label patterns'),
'restrict access' => TRUE,
];
return $permissions;
}