You are here

public function TestSearch::createQuery in Search API Autocomplete 8

Creates a search query based on this search.

Parameters

string $keys: The keywords to set on the query, if possible. Otherwise, this parameter can also be ignored.

array $data: (optional) Additional data passed to the callback.

Return value

\Drupal\search_api\Query\QueryInterface The created query.

Throws

\Drupal\search_api_autocomplete\SearchApiAutocompleteException Thrown if the query couldn't be created.

Overrides SearchPluginInterface::createQuery

File

tests/search_api_autocomplete_test/src/Plugin/search_api_autocomplete/search/TestSearch.php, line 62

Class

TestSearch
Defines a test search plugin class.

Namespace

Drupal\search_api_autocomplete_test\Plugin\search_api_autocomplete\search

Code

public function createQuery($keys, array $data = []) {
  $this
    ->logMethodCall(__FUNCTION__, func_get_args());
  if ($override = $this
    ->getMethodOverride(__FUNCTION__)) {
    return call_user_func($override, $this, $keys, $data);
  }
  return $this->search
    ->getIndex()
    ->query()
    ->keys($keys);
}