You are here

public function Search::addSuggester in Search API Autocomplete 8

Adds a suggester to this search.

An existing suggester with the same ID will be replaced.

Parameters

\Drupal\search_api_autocomplete\Suggester\SuggesterInterface $suggester: The suggester to be added.

Return value

$this

Overrides SearchInterface::addSuggester

File

src/Entity/Search.php, line 267

Class

Search
Describes the autocomplete settings for a certain search.

Namespace

Drupal\search_api_autocomplete\Entity

Code

public function addSuggester(SuggesterInterface $suggester) {

  // Make sure the suggesterInstances are loaded before trying to add a plugin
  // to them.
  if ($this->suggesterInstances === NULL) {
    $this
      ->getSuggesters();
  }
  $this->suggesterInstances[$suggester
    ->getPluginId()] = $suggester;
  return $this;
}