Page::getSiteRoot() 

\nn\t3::Page()->getSiteRoot($returnAll = false); 

Get PID of the site root(s). Corresponds to the page in the backend that has the "globe" as an icon (in the page properties "use as start of website")

\nn\t3::Page()->getSiteRoot();
Copied!

| @return int

Source Code 

public function getSiteRoot( $returnAll = false ) {
	$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
	$queryBuilder
		->select('*')
		->from('pages')
		->andWhere($queryBuilder->expr()->eq('is_siteroot', '1'));
	if ($returnAll) return $queryBuilder->executeQuery()->fetchAllAssociative();
	return $queryBuilder->executeQuery()->fetchAssociative();
}
Copied!