You are here

public function SearchController::setAsDefault in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/search/src/Controller/SearchController.php \Drupal\search\Controller\SearchController::setAsDefault()
  2. 9 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 228

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');
}