You are here

public function SearchExtraTypeSearch::execute 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::execute()
  2. 10 core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php \Drupal\search_extra_type\Plugin\Search\SearchExtraTypeSearch::execute()

Execute the search.

This is a dummy search, so when search "executes", we just return a dummy result containing the keywords and a list of conditions.

Return value

array A structured list of search results

Overrides SearchInterface::execute

1 call to SearchExtraTypeSearch::execute()
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/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php, line 49

Class

SearchExtraTypeSearch
Executes a dummy keyword search.

Namespace

Drupal\search_extra_type\Plugin\Search

Code

public function execute() {
  $results = [];
  if (!$this
    ->isSearchExecutable()) {
    return $results;
  }
  return [
    [
      'link' => Url::fromRoute('test_page_test.test_page')
        ->toString(),
      'type' => 'Dummy result type',
      'title' => 'Dummy title',
      'snippet' => new FormattableMarkup("Dummy search snippet to display. Keywords: @keywords\n\nConditions: @search_parameters", [
        '@keywords' => $this->keywords,
        '@search_parameters' => print_r($this->searchParameters, TRUE),
      ]),
    ],
  ];
}