public function Query::postExecute in Search API 8
Postprocesses the search results before they are returned.
This method should always be called by execute() and contain all necessary operations after the results are returned from the server.
Overrides QueryInterface::postExecute
2 calls to Query::postExecute()
- Query::execute in src/
Query/ Query.php - Executes this search query.
- Query::shouldAbort in src/
Query/ Query.php - Determines whether the query should be aborted.
File
- src/
Query/ Query.php, line 604
Class
- Query
- Provides a standard implementation for a Search API query.
Namespace
Drupal\search_api\QueryCode
public function postExecute() {
if ($this->processingLevel == self::PROCESSING_NONE) {
return;
}
// Postprocess results.
$this->index
->postprocessSearchResults($this->results);
// Let modules alter the results.
$event_base_name = SearchApiEvents::PROCESSING_RESULTS;
$event = new ProcessingResultsEvent($this->results);
$this
->getEventDispatcher()
->dispatch($event_base_name, $event);
$this->results = $event
->getResults();
$hooks = [
'search_api_results',
];
foreach ($this->tags as $tag) {
$hooks[] = "search_api_results_{$tag}";
$event = new ProcessingResultsEvent($this->results);
$this
->getEventDispatcher()
->dispatch("{$event_base_name}.{$tag}", $event);
$this->results = $event
->getResults();
}
$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.processing_results" event instead. See https://www.drupal.org/node/3059866';
$this
->getModuleHandler()
->alterDeprecated($description, $hooks, $this->results);
// Store the results in the static cache.
$this
->getQueryHelper()
->addResults($this->results);
}