protected static function BackendTrait::getBackend in Search API Solr 8.3
Same name in this branch
- 8.3 src/Controller/BackendTrait.php \Drupal\search_api_solr\Controller\BackendTrait::getBackend()
- 8.3 src/Plugin/search_api_autocomplete/suggester/BackendTrait.php \Drupal\search_api_solr\Plugin\search_api_autocomplete\suggester\BackendTrait::getBackend()
Same name and namespace in other branches
- 4.x src/Plugin/search_api_autocomplete/suggester/BackendTrait.php \Drupal\search_api_solr\Plugin\search_api_autocomplete\suggester\BackendTrait::getBackend()
Retrieves the backend for the given index, if it supports autocomplete.
Parameters
\Drupal\search_api\IndexInterface $index: The search index.
Return value
\Drupal\search_api_solr\SolrAutocompleteInterface|null The backend plugin of the index's server, if it exists and supports autocomplete; NULL otherwise.
5 calls to BackendTrait::getBackend()
- Spellcheck::getAutocompleteSuggestions in src/
Plugin/ search_api_autocomplete/ suggester/ Spellcheck.php - Spellcheck::supportsSearch in src/
Plugin/ search_api_autocomplete/ suggester/ Spellcheck.php - Suggester::getAutocompleteSuggestions in src/
Plugin/ search_api_autocomplete/ suggester/ Suggester.php - Suggester::supportsSearch in src/
Plugin/ search_api_autocomplete/ suggester/ Suggester.php - Terms::getAutocompleteSuggestions in src/
Plugin/ search_api_autocomplete/ suggester/ Terms.php
File
- src/
Plugin/ search_api_autocomplete/ suggester/ BackendTrait.php, line 26
Class
- BackendTrait
- Provides a helper method for loading the search backend.
Namespace
Drupal\search_api_solr\Plugin\search_api_autocomplete\suggesterCode
protected static function getBackend(IndexInterface $index) {
try {
if (!$index
->hasValidServer()) {
return NULL;
}
$server = $index
->getServerInstance();
$backend = $server
->getBackend();
if ($backend instanceof SolrAutocompleteInterface && $server
->supportsFeature('search_api_autocomplete')) {
return $backend;
}
} catch (\Exception $e) {
$this
->logException($e);
}
return NULL;
}