public function ActionsPermissions::permissions in Views Bulk Operations (VBO) 8
Same name and namespace in other branches
- 8.3 modules/actions_permissions/src/ActionsPermissions.php \Drupal\actions_permissions\ActionsPermissions::permissions()
- 8.2 modules/actions_permissions/src/ActionsPermissions.php \Drupal\actions_permissions\ActionsPermissions::permissions()
- 4.0.x modules/actions_permissions/src/ActionsPermissions.php \Drupal\actions_permissions\ActionsPermissions::permissions()
Get permissions for Actions.
Return value
array Permissions array.
1 string reference to 'ActionsPermissions::permissions'
- actions_permissions.permissions.yml in modules/
actions_permissions/ actions_permissions.permissions.yml - modules/actions_permissions/actions_permissions.permissions.yml
File
- modules/
actions_permissions/ src/ ActionsPermissions.php, line 61
Class
- ActionsPermissions
- Create permissions for existing actions.
Namespace
Drupal\actions_permissionsCode
public function permissions() {
$permissions = [];
$entity_type_definitions = $this->entityTypeManager
->getDefinitions();
// Get definitions that will not be altered by actions_permissions.
foreach ($this->actionManager
->getDefinitions([
'skip_actions_permissions' => TRUE,
'nocache' => TRUE,
]) as $definition) {
// Skip actions that define their own requirements.
if (!empty($definition['requirements'])) {
continue;
}
$id = 'execute ' . $definition['id'];
$entity_type = NULL;
if (empty($definition['type'])) {
$entity_type = $this
->t('all entity types');
$id .= ' all';
}
elseif (isset($entity_type_definitions[$definition['type']])) {
$entity_type = $entity_type_definitions[$definition['type']]
->getLabel();
$id .= ' ' . $definition['type'];
}
if (isset($entity_type)) {
$permissions[$id] = [
'title' => $this
->t('Execute the %action action on %type.', [
'%action' => $definition['label'],
'%type' => $entity_type,
]),
];
}
}
// Rebuild VBO action definitions cache with
// included action_permissions modifications.
$this->actionManager
->getDefinitions([
'nocache' => TRUE,
]);
return $permissions;
}