You are here

public function SuggestionFactory::createFromSuggestionSuffix in Search API Autocomplete 8

Creates a suggestion from a suggested suffix to the user input.

Parameters

string $suggestion_suffix: The suggestion suffix.

int|null $results_count: (optional) The estimated number of results.

Return value

\Drupal\search_api_autocomplete\Suggestion\SuggestionInterface An autocomplete suggestion.

File

src/Suggestion/SuggestionFactory.php, line 83

Class

SuggestionFactory
Provides factory methods for simpler creation of autocomplete suggestions.

Namespace

Drupal\search_api_autocomplete\Suggestion

Code

public function createFromSuggestionSuffix($suggestion_suffix, $results_count = NULL) {
  $suggestion = new Suggestion();
  $suggestion
    ->setUserInput($this->userInput);
  $suggestion
    ->setSuggestionSuffix($suggestion_suffix);
  if ($results_count !== NULL) {
    $suggestion
      ->setResultsCount($results_count);
  }
  return $suggestion;
}