protected function SearchApiAlgoliaBackend::connect in Search API Algolia 3.0.x
Same name and namespace in other branches
- 8 src/Plugin/search_api/backend/SearchApiAlgoliaBackend.php \Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend::connect()
- 2.0.x src/Plugin/search_api/backend/SearchApiAlgoliaBackend.php \Drupal\search_api_algolia\Plugin\search_api\backend\SearchApiAlgoliaBackend::connect()
Creates a connection to the Algolia Search server as configured.
Parameters
\Drupal\search_api\IndexInterface|null $index: Index to connect to.
string $index_suffix: Index suffix, specified when connecting to replica or query suggestion.
string $langcode: Language code to connect to. Specified when doing operations on both languages together.
6 calls to SearchApiAlgoliaBackend::connect()
- SearchApiAlgoliaBackend::deleteAllIndexItems in src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php - SearchApiAlgoliaBackend::deleteItems in src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php - SearchApiAlgoliaBackend::getAutocompleteSuggestions in src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php - Implements autocomplete compatible to AutocompleteBackendInterface.
- SearchApiAlgoliaBackend::indexItems in src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php - SearchApiAlgoliaBackend::search in src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php
File
- src/
Plugin/ search_api/ backend/ SearchApiAlgoliaBackend.php, line 568
Class
- SearchApiAlgoliaBackend
- Class SearchApiAlgoliaBackend.
Namespace
Drupal\search_api_algolia\Plugin\search_api\backendCode
protected function connect(?IndexInterface $index = NULL, $index_suffix = '', $langcode = '') {
if (!$this
->getAlgolia() instanceof SearchClient) {
$this->algoliaClient = SearchClient::create($this
->getApplicationId(), $this
->getApiKey());
}
if ($index && $index instanceof IndexInterface) {
$indexId = $index
->getOption('algolia_index_name') ? $index
->getOption('algolia_index_name') : $index
->get('id');
if ($this
->isLanguageSuffixEnabled($index)) {
$langcode = $langcode ?: $this->languageManager
->getCurrentLanguage()
->getId();
$indexId .= '_' . $langcode;
}
$indexId .= $index_suffix;
$this
->setAlgoliaIndex($this->algoliaClient
->initIndex($indexId));
}
}