You are here

public function SearchPluginBase::buildResults in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/search/src/Plugin/SearchPluginBase.php \Drupal\search\Plugin\SearchPluginBase::buildResults()
  2. 10 core/modules/search/src/Plugin/SearchPluginBase.php \Drupal\search\Plugin\SearchPluginBase::buildResults()

Executes the search and builds render arrays for the result items.

Return value

array An array of render arrays of search result items (generally each item has '#theme' set to 'search_result'), or an empty array if there are no results.

Overrides SearchInterface::buildResults

1 method overrides SearchPluginBase::buildResults()
SearchExtraTypeSearch::buildResults in core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php
Executes the search and builds render arrays for the result items.

File

core/modules/search/src/Plugin/SearchPluginBase.php, line 97

Class

SearchPluginBase
Defines a base class for plugins wishing to support search.

Namespace

Drupal\search\Plugin

Code

public function buildResults() {
  $results = $this
    ->execute();
  $built = [];
  foreach ($results as $result) {
    $built[] = [
      '#theme' => 'search_result',
      '#result' => $result,
      '#plugin_id' => $this
        ->getPluginId(),
    ];
  }
  return $built;
}