You are here

protected function SearchApiPageController::finishBuildWithoutResults in Search API Pages 8

Adds the no results text and then finishes the build.

Parameters

array $build: The build to finish.

\Drupal\search_api_page\SearchApiPageInterface $searchApiPage: The Search API page entity.

Return value

array The finished build render array.

1 call to SearchApiPageController::finishBuildWithoutResults()
SearchApiPageController::page in src/Controller/SearchApiPageController.php
Page callback.

File

src/Controller/SearchApiPageController.php, line 278

Class

SearchApiPageController
Defines a controller to serve search pages.

Namespace

Drupal\search_api_page\Controller

Code

protected function finishBuildWithoutResults(array $build, SearchApiPageInterface $searchApiPage) {
  $build['#no_results_found'] = [
    '#markup' => $this
      ->t('Your search yielded no results.'),
  ];
  $build['#search_help'] = [
    '#markup' => $this
      ->t('<ul>
<li>Check if your spelling is correct.</li>
<li>Remove quotes around phrases to search for each word individually. <em>bike shed</em> will often show more results than <em>&quot;bike shed&quot;</em>.</li>
<li>Consider loosening your query with <em>OR</em>. <em>bike OR shed</em> will often show more results than <em>bike shed</em>.</li>
</ul>'),
  ];
  return $this
    ->finishBuild($build, $searchApiPage);
}