You are here

protected static function Suggester::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

SolrAutocompleteInterface|null The backend plugin of the index's server, if it exists and supports autocomplete; NULL otherwise.

Throws

\Drupal\search_api\SearchApiException

2 calls to Suggester::getBackend()
Suggester::getAutocompleteSuggestions in src/Plugin/search_api_autocomplete/suggester/Suggester.php
Retrieves autocompletion suggestions for some user input.
Suggester::supportsSearch in src/Plugin/search_api_autocomplete/suggester/Suggester.php
Determines whether this plugin supports the given search.

File

src/Plugin/search_api_autocomplete/suggester/Suggester.php, line 141

Class

Suggester
Provides a suggester plugin that retrieves suggestions from the server.

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;
}