You are here

public function SearchApiAutocompleteSearch::getSuggester in Search API Autocomplete 7

Retrieves the suggester plugin for this search.

Parameters

bool $reset: (optional) If TRUE, clear the internal static cache and reload the suggester.

Return value

SearchApiAutocompleteSuggesterInterface|null This search's suggester plugin, or NULL if it could not be loaded.

1 call to SearchApiAutocompleteSearch::getSuggester()
SearchApiAutocompleteSearch::supportsAutocompletion in ./search_api_autocomplete.entity.php
Determines whether autocompletion is currently supported for this search.

File

./search_api_autocomplete.entity.php, line 148
Contains SearchApiAutocompleteSearch.

Class

SearchApiAutocompleteSearch
Describes the autocomplete settings for a certain search.

Code

public function getSuggester($reset = FALSE) {
  if (!isset($this->suggester) || $reset) {
    $configuration = !empty($this->options['suggester_configuration']) ? $this->options['suggester_configuration'] : array();
    $this->suggester = search_api_autocomplete_suggester_load($this->suggester_id, $this, $configuration);
    if (!$this->suggester) {
      $variables['@search'] = $this->machine_name;
      $variables['@index'] = $this
        ->index() ? $this
        ->index()
        ->label() : $this->index_id;
      $variables['@suggester_id'] = $this->suggester_id;
      watchdog('search_api_autocomplete', 'Autocomplete search @search on index @index specifies an invalid suggester plugin @suggester_id.', $variables, WATCHDOG_ERROR);
      $this->suggester = FALSE;
    }
  }
  return $this->suggester ? $this->suggester : NULL;
}