function SearchController::setAsDefault

Same name in other branches
  1. 9 core/modules/search/src/Controller/SearchController.php \Drupal\search\Controller\SearchController::setAsDefault()
  2. 8.9.x core/modules/search/src/Controller/SearchController.php \Drupal\search\Controller\SearchController::setAsDefault()
  3. 10 core/modules/search/src/Controller/SearchController.php \Drupal\search\Controller\SearchController::setAsDefault()

Sets the search page as the default.

Parameters

\Drupal\search\SearchPageInterface $search_page: The search page entity.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse A redirect to the search settings page.

1 string reference to 'SearchController::setAsDefault'
search.routing.yml in core/modules/search/search.routing.yml
core/modules/search/search.routing.yml

File

core/modules/search/src/Controller/SearchController.php, line 219

Class

SearchController
Route controller for search.

Namespace

Drupal\search\Controller

Code

public function setAsDefault(SearchPageInterface $search_page) {
    // Set the default page to this search page.
    $this->searchPageRepository
        ->setDefaultSearchPage($search_page);
    $this->messenger()
        ->addStatus($this->t('The default search page is now %label. Be sure to check the ordering of your search pages.', [
        '%label' => $search_page->label(),
    ]));
    return $this->redirect('entity.search_page.collection');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.