public function ActionsPermissionsEventSubscriber::alterActions in Views Bulk Operations (VBO) 8
Same name and namespace in other branches
- 8.3 modules/actions_permissions/src/EventSubscriber/ActionsPermissionsEventSubscriber.php \Drupal\actions_permissions\EventSubscriber\ActionsPermissionsEventSubscriber::alterActions()
- 8.2 modules/actions_permissions/src/EventSubscriber/ActionsPermissionsEventSubscriber.php \Drupal\actions_permissions\EventSubscriber\ActionsPermissionsEventSubscriber::alterActions()
- 4.0.x modules/actions_permissions/src/EventSubscriber/ActionsPermissionsEventSubscriber.php \Drupal\actions_permissions\EventSubscriber\ActionsPermissionsEventSubscriber::alterActions()
Alter the actions' definitions.
The event to respond to.
File
- modules/
actions_permissions/ src/ EventSubscriber/ ActionsPermissionsEventSubscriber.php, line 34
Class
- ActionsPermissionsEventSubscriber
- Defines module event subscriber class.
Namespace
Drupal\actions_permissions\EventSubscriberCode
public function alterActions(Event $event) {
// Don't alter definitions if this is invoked by the
// own permissions creating method.
if (!empty($event->alterParameters['skip_actions_permissions'])) {
return;
}
foreach ($event->definitions as $action_id => $definition) {
// Only process actions that don't define their own requirements.
if (empty($definition['requirements'])) {
$permission_id = 'execute ' . $definition['id'];
if (empty($definition['type'])) {
$permission_id .= ' all';
}
else {
$permission_id .= ' ' . $definition['type'];
}
$definition['requirements']['_permission'] = $permission_id;
$event->definitions[$action_id] = $definition;
}
}
}