You are here

interface SuggesterInterface in Search API Autocomplete 8

Represents a plugin for creating autocomplete suggestions.

Hierarchy

Expanded class hierarchy of SuggesterInterface

All classes that implement SuggesterInterface

See also

\Drupal\search_api_autocomplete\Annotation\SearchApiAutocompleteSuggester

\Drupal\search_api_autocomplete\Suggester\SuggesterManager

\Drupal\search_api_autocomplete\Suggester\SuggesterPluginBase

Plugin API

3 files declare their use of SuggesterInterface
Search.php in src/Entity/Search.php
SearchEditForm.php in src/Form/SearchEditForm.php
SearchInterface.php in src/SearchInterface.php

File

src/Suggester/SuggesterInterface.php, line 17

Namespace

Drupal\search_api_autocomplete\Suggester
View source
interface SuggesterInterface extends PluginInterface {

  /**
   * Determines whether this plugin supports the given search.
   *
   * @param \Drupal\search_api_autocomplete\SearchInterface $search
   *   The search in question.
   *
   * @return bool
   *   TRUE if this plugin supports the given search, FALSE otherwise.
   */
  public static function supportsSearch(SearchInterface $search);

  /**
   * Alters an autocomplete element that should use this suggester.
   *
   * This method is usually not needed by suggester plugins, but can be
   * implemented when necessary to, for example, pass additional information to
   * the autocomplete AJAX callback.
   *
   * @param array $element
   *   The render array of the autocomplete element.
   */
  public function alterAutocompleteElement(array &$element);

  /**
   * Retrieves autocompletion suggestions for some user input.
   *
   * For example, when given the user input "teach us", with "us" being
   * considered incomplete, \Drupal\search_api_autocomplete\SuggestionInterface
   * objects representing the following suggestions might be returned:
   *
   * @code
   *   [
   *     [
   *       'prefix' => t('Did you mean:'),
   *       'user_input' => 'reach us',
   *     ],
   *     [
   *       'user_input' => 'teach us',
   *       'suggestion_suffix' => 'ers',
   *     ],
   *     [
   *       'user_input' => 'teach us',
   *       'suggestion_suffix' => ' swimming',
   *     ],
   *   ];
   * @endcode
   *
   * @param \Drupal\search_api\Query\QueryInterface $query
   *   A query representing the completed user input so far.
   * @param string $incomplete_key
   *   The start of another fulltext keyword for the search, which should be
   *   completed. Might be empty, in which case all user input up to now was
   *   considered completed. Then, additional keywords for the search could be
   *   suggested.
   * @param string $user_input
   *   The complete user input for the fulltext search keywords so far.
   *
   * @return \Drupal\search_api_autocomplete\Suggestion\SuggestionInterface[]
   *   An array of autocomplete suggestions.
   */
  public function getAutocompleteSuggestions(QueryInterface $query, $incomplete_key, $user_input);

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurableInterface::defaultConfiguration public function Gets default configuration for this plugin. 11
ConfigurableInterface::getConfiguration public function Gets this plugin's configuration. 12
ConfigurableInterface::setConfiguration public function Sets the configuration for this plugin instance. 12
ConfigurablePluginInterface::getDescription public function Returns the plugin's description. 1
ConfigurablePluginInterface::label public function Returns the label for use on the administration pages. 1
ConfigurablePluginInterface::onDependencyRemoval public function Informs the plugin that some of its dependencies are being removed. 1
ContainerFactoryPluginInterface::create public static function Creates an instance of the plugin. 112
DependentPluginInterface::calculateDependencies public function Calculates dependencies for the configured plugin. 19
DerivativeInspectionInterface::getBaseId public function Gets the base_plugin_id of the plugin instance. 1
DerivativeInspectionInterface::getDerivativeId public function Gets the derivative_id of the plugin instance. 1
HideablePluginInterface::isHidden public function Determines whether this plugin should be hidden in the UI. 1
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 4
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2
PluginInterface::getSearch public function Retrieves the search this plugin is configured for. 1
PluginInterface::setSearch public function Sets the search this plugin is configured for. 1
SuggesterInterface::alterAutocompleteElement public function Alters an autocomplete element that should use this suggester. 1
SuggesterInterface::getAutocompleteSuggestions public function Retrieves autocompletion suggestions for some user input. 4
SuggesterInterface::supportsSearch public static function Determines whether this plugin supports the given search. 1