You are here

public function SearchApiRenderedItem::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 FieldPluginBase::init

File

src/Plugin/views/field/SearchApiRenderedItem.php, line 49

Class

SearchApiRenderedItem
Handles rendering an entity in a certain view mode in Search API Views.

Namespace

Drupal\search_api\Plugin\views\field

Code

public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
  parent::init($view, $display, $options);
  $base_table = $view->storage
    ->get('base_table');
  $this->index = SearchApiQuery::getIndexFromTable($base_table, $this
    ->getEntityTypeManager());
  if (!$this->index) {
    $view_label = $view->storage
      ->label();
    throw new \InvalidArgumentException("View '{$view_label}' is not based on Search API but tries to use its row plugin.");
  }
}