You are here

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

Expanded class hierarchy of ViewsBulkOperationsEventSubscriber

See also

\Drupal\views_bulk_operations\EventSubscriber\ViewsBulkOperationsEventSubscriber

1 string reference to 'ViewsBulkOperationsEventSubscriber'
search_api.services.yml in ./search_api.services.yml
search_api.services.yml
1 service uses ViewsBulkOperationsEventSubscriber
search_api.vbo_view_data_provider in ./search_api.services.yml
Drupal\search_api\Contrib\ViewsBulkOperationsEventSubscriber

File

src/Contrib/ViewsBulkOperationsEventSubscriber.php, line 17

Namespace

Drupal\search_api\Contrib
View 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

Namesort descending Modifiers Type Description Overrides
ViewsBulkOperationsEventSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
ViewsBulkOperationsEventSubscriber::provideViewData public function Responds to view data request events.