public function ElasticsearchViewsQuery::init in Elasticsearch Connector 8.7
Same name and namespace in other branches
- 8.2 modules/elasticsearch_connector_views/src/Plugin/views/query/ElasticsearchViewsQuery.php \Drupal\elasticsearch_connector_views\Plugin\views\query\ElasticsearchViewsQuery::init()
- 8.5 modules/elasticsearch_connector_views/src/Plugin/views/query/ElasticsearchViewsQuery.php \Drupal\elasticsearch_connector_views\Plugin\views\query\ElasticsearchViewsQuery::init()
- 8.6 modules/elasticsearch_connector_views/src/Plugin/views/query/ElasticsearchViewsQuery.php \Drupal\elasticsearch_connector_views\Plugin\views\query\ElasticsearchViewsQuery::init()
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 PluginBase::init
File
- modules/
elasticsearch_connector_views/ src/ Plugin/ views/ query/ ElasticsearchViewsQuery.php, line 172
Class
- ElasticsearchViewsQuery
- Defines a Views query class for searching on Search API indexes.
Namespace
Drupal\elasticsearch_connector_views\Plugin\views\queryCode
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
try {
parent::init($view, $display, $options);
$view_id = $this->view->storage
->get('base_table');
$data = Views::viewsData()
->get($view_id);
$cluster_id = $data['table']['base']['cluster_id'];
$this->index = $data['table']['base']['index'];
$this->elasticsearchCluster = $this->entityTypeManager
->getStorage('elasticsearch_cluster')
->load($cluster_id);
$clientManager = \Drupal::service('elasticsearch_connector.client_manager');
$this->elasticsearchClient = $clientManager
->getClientForCluster($this->elasticsearchCluster);
} catch (\Exception $e) {
$this
->abort($e
->getMessage());
}
}