class ViewsBulkOperationsEventSubscriber in Views Bulk Operations (VBO) 8.3
Same name and namespace in other branches
- 8 src/EventSubscriber/ViewsBulkOperationsEventSubscriber.php \Drupal\views_bulk_operations\EventSubscriber\ViewsBulkOperationsEventSubscriber
- 8.2 src/EventSubscriber/ViewsBulkOperationsEventSubscriber.php \Drupal\views_bulk_operations\EventSubscriber\ViewsBulkOperationsEventSubscriber
- 4.0.x src/EventSubscriber/ViewsBulkOperationsEventSubscriber.php \Drupal\views_bulk_operations\EventSubscriber\ViewsBulkOperationsEventSubscriber
Defines module event subscriber class.
Allows getting data of core entity views.
Hierarchy
- class \Drupal\views_bulk_operations\EventSubscriber\ViewsBulkOperationsEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ViewsBulkOperationsEventSubscriber
1 string reference to 'ViewsBulkOperationsEventSubscriber'
1 service uses ViewsBulkOperationsEventSubscriber
File
- src/
EventSubscriber/ ViewsBulkOperationsEventSubscriber.php, line 14
Namespace
Drupal\views_bulk_operations\EventSubscriberView source
class ViewsBulkOperationsEventSubscriber implements EventSubscriberInterface {
// Subscribe to the VBO event with high priority
// to prepopulate the event data.
const PRIORITY = 999;
/**
* Object that gets the current view data.
*
* @var \Drupal\views_bulk_operations\Service\ViewsbulkOperationsViewDataInterface
*/
protected $viewData;
/**
* Object constructor.
*
* @param \Drupal\views_bulk_operations\Service\ViewsBulkOperationsViewDataInterface $viewData
* The VBO View Data provider service.
*/
public function __construct(ViewsBulkOperationsViewDataInterface $viewData) {
$this->viewData = $viewData;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[ViewsBulkOperationsEvent::NAME][] = [
'provideViewData',
self::PRIORITY,
];
return $events;
}
/**
* Respond to view data request event.
*
* @var \Drupal\views_bulk_operations\ViewsBulkOperationsEvent $event
* The event to respond to.
*/
public function provideViewData(ViewsBulkOperationsEvent $event) {
$view_data = $event
->getViewData();
if (!empty($view_data['table']['entity type'])) {
$event
->setEntityTypeIds([
$view_data['table']['entity type'],
]);
$event
->setEntityGetter([
'callable' => [
$this->viewData,
'getEntityDefault',
],
]);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ViewsBulkOperationsEventSubscriber:: |
protected | property | Object that gets the current view data. | |
ViewsBulkOperationsEventSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ViewsBulkOperationsEventSubscriber:: |
constant | |||
ViewsBulkOperationsEventSubscriber:: |
public | function | Respond to view data request event. | |
ViewsBulkOperationsEventSubscriber:: |
public | function | Object constructor. |