buildResults example

    // GET parameters. Note that we need to try the search if 'keys' is in     // there at all, vs. being empty, due to advanced search.     $results = [];
    if ($request->query->has('keys')) {
      if ($plugin->isSearchExecutable()) {
        // Log the search.         if ($this->config('search.settings')->get('logging')) {
          $this->logger->notice('Searched %type for %keys.', ['%keys' => $keys, '%type' => $entity->label()]);
        }

        // Collect the search results.         $results = $plugin->buildResults();
      }
      else {
        // The search not being executable means that no keywords or other         // conditions were entered.         $this->messenger()->addError($this->t('Please enter some keywords.'));
      }
    }

    if (count($results)) {
      $build['search_results_title'] = [
        '#markup' => '<h2>' . $this->t('Search results') . '</h2>',
      ];
Home | Imprint | This part of the site doesn't use cookies.