function SearchQuery::searchExpression

Same name and namespace in other branches
  1. 10 core/modules/search/src/SearchQuery.php \Drupal\search\SearchQuery::searchExpression()
  2. 11.x core/modules/search/src/SearchQuery.php \Drupal\search\SearchQuery::searchExpression()
  3. 9 core/modules/search/src/SearchQuery.php \Drupal\search\SearchQuery::searchExpression()
  4. 8.9.x core/modules/search/src/SearchQuery.php \Drupal\search\SearchQuery::searchExpression()

Sets up the search query expression.

Parameters

$query: A search query string, which can contain options.

$module: The search module. This maps to {search_index}.type in the database.

Return value

The SearchQuery object.

File

modules/search/search.extender.inc, line 148

Class

SearchQuery
Do a query on the full-text search index for a word or words.

Code

public function searchExpression($expression, $module) {
  $this->searchExpression = $expression;
  $this->type = $module;
  // Add a search_* tag. This needs to be added before any preExecute methods
  // for decorated queries are called, as $this->prepared will be set to TRUE
  // and tags added in the execute method will never get used. For example,
  // if $query is extended by 'SearchQuery' then 'PagerDefault', the
  // search-specific tag will be added too late (when preExecute() has
  // already been called from the PagerDefault extender), and as a
  // consequence will not be available to hook_query_alter() implementations,
  // nor will the correct hook_query_TAG_alter() implementations get invoked.
  // See node_search_execute().
  $this->addTag('search_' . $module);
  return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.