class ActionsPermissionsEventSubscriber 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
- 8.2 modules/actions_permissions/src/EventSubscriber/ActionsPermissionsEventSubscriber.php \Drupal\actions_permissions\EventSubscriber\ActionsPermissionsEventSubscriber
- 4.0.x modules/actions_permissions/src/EventSubscriber/ActionsPermissionsEventSubscriber.php \Drupal\actions_permissions\EventSubscriber\ActionsPermissionsEventSubscriber
Defines module event subscriber class.
Alters actions to make use of permissions created by the module.
Hierarchy
- class \Drupal\actions_permissions\EventSubscriber\ActionsPermissionsEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ActionsPermissionsEventSubscriber
1 string reference to 'ActionsPermissionsEventSubscriber'
- actions_permissions.services.yml in modules/
actions_permissions/ actions_permissions.services.yml - modules/actions_permissions/actions_permissions.services.yml
1 service uses ActionsPermissionsEventSubscriber
File
- modules/
actions_permissions/ src/ EventSubscriber/ ActionsPermissionsEventSubscriber.php, line 14
Namespace
Drupal\actions_permissions\EventSubscriberView source
class ActionsPermissionsEventSubscriber implements EventSubscriberInterface {
// Subscribe to the VBO event with low priority
// to let other modules alter requirements first.
const PRIORITY = -999;
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[ViewsBulkOperationsActionManager::ALTER_ACTIONS_EVENT][] = [
'alterActions',
static::PRIORITY,
];
return $events;
}
/**
* Alter the actions' definitions.
*
* @var \Symfony\Component\EventDispatcher\Event $event
* The event to respond to.
*/
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;
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ActionsPermissionsEventSubscriber:: |
public | function | Alter the actions' definitions. | |
ActionsPermissionsEventSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ActionsPermissionsEventSubscriber:: |
constant |