SearchPageRepository::getDefaultSearchPage

public SearchPageRepository::getDefaultSearchPage()

Returns the default search page.

Return value

\Drupal\search\SearchPageInterface|bool The search page entity, or FALSE if no pages are active.

Overrides SearchPageRepositoryInterface::getDefaultSearchPage

File

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

Class

SearchPageRepository
Provides a repository for Search Page config entities.

Namespace

Drupal\search

Code

public function getDefaultSearchPage() {
  // Find all active search pages (without loading them).
  $search_pages = $this->getQuery()
    ->condition('status', TRUE)
    ->execute();

  // If the default page is active, return it.
  $default = $this->configFactory->get('search.settings')->get('default_page');
  if (isset($search_pages[$default])) {
    return $default;
  }

  // Otherwise, use the first active search page.
  return is_array($search_pages) ? reset($search_pages) : FALSE;
}
doc_Drupal
2016-10-29 09:40:45
Comments
Leave a Comment

Please login to continue.