public function Query::preExecute in Search API 8
Prepares the query object for the search.
This method should always be called by execute() and contain all necessary operations that have to be execute before the query is passed to the server's search() method.
Overrides QueryInterface::preExecute
1 call to Query::preExecute()
- Query::execute in src/
Query/ Query.php - Executes this search query.
File
- src/
Query/ Query.php, line 569
Class
- Query
- Provides a standard implementation for a Search API query.
Namespace
Drupal\search_api\QueryCode
public function preExecute() {
// Make sure to only execute this once per query, and not for queries with
// the "none" processing level.
if (!$this->preExecuteRan) {
$this->originalQuery = clone $this;
$this->originalQuery->executed = FALSE;
$this->preExecuteRan = TRUE;
if ($this->processingLevel == self::PROCESSING_NONE) {
return;
}
// Preprocess query.
$this->index
->preprocessSearchQuery($this);
// Let modules alter the query.
$event_base_name = SearchApiEvents::QUERY_PRE_EXECUTE;
$event = new QueryPreExecuteEvent($this);
$this
->getEventDispatcher()
->dispatch($event_base_name, $event);
$hooks = [
'search_api_query',
];
foreach ($this->tags as $tag) {
$hooks[] = "search_api_query_{$tag}";
$event_name = "{$event_base_name}.{$tag}";
$event = new QueryPreExecuteEvent($this);
$this
->getEventDispatcher()
->dispatch($event_name, $event);
}
$description = 'This hook is deprecated in search_api:8.x-1.14 and is removed from search_api:2.0.0. Please use the "search_api.query_pre_execute" event instead. See https://www.drupal.org/node/3059866';
$this
->getModuleHandler()
->alterDeprecated($description, $hooks, $this);
}
}