You are here

public function SearchExtraTypeSearch::buildResults in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php \Drupal\search_extra_type\Plugin\Search\SearchExtraTypeSearch::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 SearchPluginBase::buildResults

File

core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php, line 67

Class

SearchExtraTypeSearch
Executes a dummy keyword search.

Namespace

Drupal\search_extra_type\Plugin\Search

Code

public function buildResults() {
  $results = $this
    ->execute();
  $output['prefix']['#markup'] = '<h2>Test page text is here</h2> <ol class="search-results">';
  foreach ($results as $entry) {
    $output[] = [
      '#theme' => 'search_result',
      '#result' => $entry,
      '#plugin_id' => 'search_extra_type_search',
    ];
  }
  $pager = [
    '#type' => 'pager',
  ];
  $output['suffix']['#markup'] = '</ol>' . \Drupal::service('renderer')
    ->render($pager);
  return $output;
}