public function SearchApiElasticsearchBackend::__construct in Elasticsearch Connector 8.7
Same name and namespace in other branches
- 8 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::__construct()
- 8.2 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::__construct()
- 8.5 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::__construct()
- 8.6 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::__construct()
SearchApiElasticsearchBackend constructor.
Parameters
array $configuration: A configuration array containing information about the plugin instance.
string $plugin_id: The plugin_id for the plugin instance.
array $plugin_definition: The plugin implementation definition.
\Drupal\Core\Form\FormBuilderInterface $form_builder: Form builder service.
\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: Module handler service.
\Drupal\elasticsearch_connector\ElasticSearch\ClientManagerInterface $client_manager: Client manager service.
\Drupal\Core\Config\Config $elasticsearch_settings: Elasticsearch settings object.
\Psr\Log\LoggerInterface $logger: Logger.
\Drupal\elasticsearch_connector\ClusterManager $cluster_manager: The cluster manager service.
\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager service.
\Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory $indexFactory: Index factory.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\search_api\SearchApiException
Overrides BackendPluginBase::__construct
File
- src/
Plugin/ search_api/ backend/ SearchApiElasticsearchBackend.php, line 172
Class
- SearchApiElasticsearchBackend
- Elasticsearch Search API Backend definition.
Namespace
Drupal\elasticsearch_connector\Plugin\search_api\backendCode
public function __construct(array $configuration, $plugin_id, array $plugin_definition, FormBuilderInterface $form_builder, ModuleHandlerInterface $module_handler, ClientManagerInterface $client_manager, Config $elasticsearch_settings, LoggerInterface $logger, ClusterManager $cluster_manager, EntityTypeManagerInterface $entity_type_manager, IndexFactory $indexFactory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->formBuilder = $form_builder;
$this->moduleHandler = $module_handler;
$this->clientManager = $client_manager;
$this->logger = $logger;
$this->elasticsearchSettings = $elasticsearch_settings;
$this->clusterManager = $cluster_manager;
$this->entityTypeManager = $entity_type_manager;
$this->indexFactory = $indexFactory;
if (empty($this->configuration['cluster_settings']['cluster'])) {
$this->configuration['cluster_settings']['cluster'] = $this->clusterManager
->getDefaultCluster();
}
$this->cluster = $this->entityTypeManager
->getStorage('elasticsearch_cluster')
->load($this->configuration['cluster_settings']['cluster']);
if (!isset($this->cluster)) {
throw new SearchApiException($this
->t('Cannot load the Elasticsearch cluster for your index.'));
}
$this->client = $this->clientManager
->getClientForCluster($this->cluster);
}