public function SearchApiElasticsearchBackend::__construct in Elasticsearch Connector 8.2
Same name and namespace in other branches
- 8.7 src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::__construct()
- 8 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:
string $plugin_id:
array $plugin_definition:
\Drupal\Core\Form\FormBuilderInterface $form_builder:
\Drupal\Core\Extension\ModuleHandlerInterface $module_handler:
ClientManagerInterface $client_manager:
\Drupal\Core\Config\Config $elasticsearch_settings:
- @param LoggerInterface $logger
Overrides BackendPluginBase::__construct
File
- src/
Plugin/ search_api/ backend/ SearchApiElasticsearchBackend.php, line 79 - Contains the SearchApiElasticsearchBackend object.
Class
- SearchApiElasticsearchBackend
- Plugin annotation @SearchApiBackend( id = "elasticsearch", label = @Translation("Elasticsearch"), description = @Translation("Index items using an Elasticsearch server.") )
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) {
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;
if (empty($this->configuration['cluster_settings']['cluster'])) {
$this->configuration['cluster_settings']['cluster'] = Cluster::getDefaultCluster();
}
$this->cluster = 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);
}