suggestedTitle example

$build = [];
    $plugin = $entity->getPlugin();

    // Build the form first, because it may redirect during the submit,     // and we don't want to build the results based on last time's request.     $build['#cache']['contexts'][] = 'url.query_args:keys';
    if ($request->query->has('keys')) {
      $keys = trim($request->query->get('keys'));
      $plugin->setSearch($keys$request->query->all()$request->attributes->all());
    }

    $build['#title'] = $plugin->suggestedTitle();
    $build['search_form'] = $this->formBuilder()->getForm(SearchPageForm::class$entity);

    // Build search results, if keywords or other search parameters are in the     // 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()]);
        }
Home | Imprint | This part of the site doesn't use cookies.