Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SearchController.php

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal