You are here

public function SearchApiBulkForm::init in Search API 8

Initialize the plugin.

Parameters

\Drupal\views\ViewExecutable $view: The view object.

\Drupal\views\Plugin\views\display\DisplayPluginBase $display: The display handler.

array $options: The options configured for this plugin.

Overrides BulkForm::init

File

src/Plugin/views/field/SearchApiBulkForm.php, line 33

Class

SearchApiBulkForm
Defines an actions-based bulk operation form element.

Namespace

Drupal\search_api\Plugin\views\field

Code

public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
  parent::init($view, $display, $options);
  $entity_type_ids = array_values($this
    ->getIndex()
    ->getEntityTypes());
  if (!$entity_type_ids) {
    $this->actions = [];
    return;
  }

  // Filter the actions to only include those that are supported by at least
  // one entity type contained in the index.
  $filter = function (ActionConfigEntityInterface $action) use ($entity_type_ids) {
    return in_array($action
      ->getType(), $entity_type_ids, TRUE);
  };
  $actions = $this->actionStorage
    ->loadMultiple();
  $this->actions = array_filter($actions, $filter);
}