You are here

public function SearchPageRepository::setDefaultSearchPage in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/search/src/SearchPageRepository.php \Drupal\search\SearchPageRepository::setDefaultSearchPage()

Sets a given search page as the default.

Parameters

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

Return value

static

Overrides SearchPageRepositoryInterface::setDefaultSearchPage

File

core/modules/search/src/SearchPageRepository.php, line 98

Class

SearchPageRepository
Provides a repository for Search Page config entities.

Namespace

Drupal\search

Code

public function setDefaultSearchPage(SearchPageInterface $search_page) {
  $this->configFactory
    ->getEditable('search.settings')
    ->set('default_page', $search_page
    ->id())
    ->save();
  $search_page
    ->enable()
    ->save();
}