class ViewsBulkOperationsEventSubscriber in Search API 8
Provides an event subscriber that interfaces with Views Bulk Operations.
This will provide VBO integration for search views by enabling VBO to retrieve the entities contained in search view result rows.
Hierarchy
- class \Drupal\search_api\Contrib\ViewsBulkOperationsEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ViewsBulkOperationsEventSubscriber
See also
\Drupal\views_bulk_operations\EventSubscriber\ViewsBulkOperationsEventSubscriber
1 string reference to 'ViewsBulkOperationsEventSubscriber'
1 service uses ViewsBulkOperationsEventSubscriber
File
- src/
Contrib/ ViewsBulkOperationsEventSubscriber.php, line 17
Namespace
Drupal\search_api\ContribView source
class ViewsBulkOperationsEventSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = [];
if (class_exists(ViewsBulkOperationsEvent::class)) {
$events[ViewsBulkOperationsEvent::NAME][] = 'provideViewData';
}
return $events;
}
/**
* Responds to view data request events.
*
* @var \Drupal\views_bulk_operations\ViewsBulkOperationsEvent $event
* The event to respond to.
*/
public function provideViewData(ViewsBulkOperationsEvent $event) {
$base_table = $event
->getView()->storage
->get('base_table');
$index = SearchApiQuery::getIndexFromTable($base_table);
if ($index) {
$event
->setEntityTypeIds($index
->getEntityTypes());
$event
->setEntityGetter([
'callable' => [
SearchApiQuery::class,
'getEntityFromRow',
],
]);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ViewsBulkOperationsEventSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ViewsBulkOperationsEventSubscriber:: |
public | function | Responds to view data request events. |