You are here

protected static function Terms::getBackend in Search API Solr 8.2

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_autocomplete\AutocompleteBackendInterface|null The backend plugin of the index's server, if it exists and supports autocomplete; NULL otherwise.

Overrides Server::getBackend

1 call to Terms::getBackend()
Terms::getAutocompleteSuggestions in src/Plugin/search_api_autocomplete/suggester/Terms.php
Retrieves autocompletion suggestions for some user input.

File

src/Plugin/search_api_autocomplete/suggester/Terms.php, line 42

Class

Terms
Provides a suggester that retrieves suggestions from Solr's Terms component.

Namespace

Drupal\search_api_solr\Plugin\search_api_autocomplete\suggester

Code

protected static function getBackend(IndexInterface $index) {
  if (!$index
    ->hasValidServer()) {
    return NULL;
  }
  $server = $index
    ->getServerInstance();
  $backend = $server
    ->getBackend();
  if ($server
    ->supportsFeature('search_api_autocomplete') && $backend instanceof SolrAutocompleteInterface) {
    return $backend;
  }
  return NULL;
}