‪TYPO3CMS  11.5
TYPO3\CMS\Core\Site\Entity\Site Class Reference
Inheritance diagram for TYPO3\CMS\Core\Site\Entity\Site:
TYPO3\CMS\Core\Site\Entity\SiteInterface

Public Member Functions

string getIdentifier ()
 
UriInterface getBase ()
 
int getRootPageId ()
 
 getDefaultLanguage ()
 
array< LanguageRef, getAvailableLanguages(BackendUserAuthentication $user, bool $includeAllLanguagesFlag=false, ?int $pageId=null):array { $availableLanguages=[];if( $includeAllLanguagesFlag &&$user->checkLanguageAccess(-1)) { $availableLanguages[-1]=new SiteLanguage(-1, '', $this->getBase(),['title'=> $this->getLanguageService() ->sL( 'LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:multipleLanguages'), 'flag'=> 'flags-multiple',]);} foreach( $this->languages as $language) { if( $user->checkLanguageAccess( $language->getLanguageId())) { $availableLanguages[ $language-> getLanguageId ()]
 
PageErrorHandlerInterface getErrorHandler (int $statusCode)
 
array getConfiguration ()
 
mixed getAttribute (string $attributeName)
 
RouterInterface getRouter (?Context $context=null)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Site\Entity\SiteInterface
SiteLanguage[] getLanguages ()
 
SiteLanguage getLanguageById (int $languageId)
 
SiteLanguage[] getAvailableLanguages (BackendUserAuthentication $user, bool $includeAllLanguagesFlag=false, ?int $pageId=null)
 

Public Attributes

$this rootPageId = $rootPageId
 
$this configuration = $configuration
 
 $configuration ['languages']
 
 $baseUrl
 
$this base = new Uri($this->sanitizeBaseUrl($baseUrl))
 
array< LanguageRef, function getLanguages():array { $languages=[];foreach( $this->languages as $languageId=> $language) { if( $language->enabled()) { $languages[ $languageId]=$language;} } return $languages;} public array< LanguageRef, function getAllLanguages():array { return $this->languages;} public SiteLanguage function getLanguageById(int $languageId):SiteLanguage { if(isset( $this->languages[ $languageId])) { return $this-> languages [$languageId]
 
return $availableLanguages
 

Protected Member Functions

foreach($configuration['languages'] as $languageConfiguration) foreach($configuration['errorHandling'] ??[] as $errorHandlingConfiguration) string resolveBaseWithVariants (string $baseUrl, ?array $baseVariants)
 
string sanitizeBaseUrl (string $base)
 
LanguageService getLanguageService ()
 

Protected Attributes

const ERRORHANDLER_TYPE_PAGE = 'Page'
 
const ERRORHANDLER_TYPE_FLUID = 'Fluid'
 
const ERRORHANDLER_TYPE_PHP = 'PHP'
 
string $identifier
 
UriInterface $base
 
int $rootPageId
 
array $configuration
 
array< LanguageRef, $languages;protected array $errorHandlers;public function __construct(string $identifier, int $rootPageId, array $configuration) { $this-> identifier = $identifier
 

Detailed Description

Entity representing a single site with available languages

@phpstan-type LanguageRef -1|0|positive-int

Definition at line 41 of file Site.php.

Member Function Documentation

◆ getAttribute()

mixed TYPO3\CMS\Core\Site\Entity\Site::getAttribute ( string  $attributeName)

Returns a single configuration attribute

Parameters
string$attributeName
Returns
‪mixed
Exceptions

Definition at line 326 of file Site.php.

References TYPO3\CMS\Core\Site\Entity\Site\configuration, and TYPO3\CMS\Core\Site\Entity\Site\identifier.

◆ getBase()

UriInterface TYPO3\CMS\Core\Site\Entity\Site::getBase ( )

Returns the base URL of this site

Returns
‪UriInterface

Implements TYPO3\CMS\Core\Site\Entity\SiteInterface.

Definition at line 189 of file Site.php.

References TYPO3\CMS\Core\Site\Entity\Site\$base.

Referenced by TYPO3\CMS\Frontend\Middleware\StaticRouteResolver\getApplicableStaticRoute().

◆ getConfiguration()

array TYPO3\CMS\Core\Site\Entity\Site::getConfiguration ( )

◆ getDefaultLanguage()

TYPO3\CMS\Core\Site\Entity\Site::getDefaultLanguage ( )

‪Returns the first language that was configured. This is usually language=0

Returns
SiteLanguage

Implements TYPO3\CMS\Core\Site\Entity\SiteInterface.

Definition at line 251 of file Site.php.

References TYPO3\CMS\Core\Site\Entity\Site\languages.

◆ getErrorHandler()

PageErrorHandlerInterface TYPO3\CMS\Core\Site\Entity\Site::getErrorHandler ( int  $statusCode)

Returns a ready-to-use error handler, to be used within the ErrorController

Parameters
int$statusCode
Returns
‪PageErrorHandlerInterface
Exceptions
PageErrorHandlerNotConfiguredException
InvalidPageErrorHandlerException

Implements TYPO3\CMS\Core\Site\Entity\SiteInterface.

Definition at line 290 of file Site.php.

References TYPO3\CMS\Core\Site\Entity\Site\ERRORHANDLER_TYPE_FLUID, TYPO3\CMS\Core\Site\Entity\Site\ERRORHANDLER_TYPE_PAGE, and TYPO3\CMS\Core\Site\Entity\Site\ERRORHANDLER_TYPE_PHP.

◆ getIdentifier()

string TYPO3\CMS\Core\Site\Entity\Site::getIdentifier ( )

◆ getLanguageId()

array<LanguageRef, getAvailableLanguages(BackendUserAuthentication $user, bool $includeAllLanguagesFlag = false, ?int $pageId = null): array { $availableLanguages = []; if ($includeAllLanguagesFlag && $user->checkLanguageAccess(-1)) { $availableLanguages[-1] = new SiteLanguage(-1, '', $this->getBase(), [ 'title' => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:multipleLanguages'), 'flag' => 'flags-multiple', ]); } foreach ($this->languages as $language) { if ($user->checkLanguageAccess($language->getLanguageId())) { $availableLanguages[$language-> TYPO3\CMS\Core\Site\Entity\Site::getLanguageId ( )
Returns
‪array<LanguageRef, SiteLanguage>

◆ getLanguageService()

LanguageService TYPO3\CMS\Core\Site\Entity\Site::getLanguageService ( )
protected

Shorthand functionality for fetching the language service

Returns
‪LanguageService

Definition at line 377 of file Site.php.

References $GLOBALS.

◆ getRootPageId()

int TYPO3\CMS\Core\Site\Entity\Site::getRootPageId ( )

◆ getRouter()

RouterInterface TYPO3\CMS\Core\Site\Entity\Site::getRouter ( ?Context  $context = null)

Returns the applicable router for this site. This might be configurable in the future.

Parameters
Context | null$context
Returns
‪RouterInterface

Definition at line 368 of file Site.php.

Referenced by TYPO3\CMS\Workspaces\Controller\PreviewController\generateUrl(), TYPO3\CMS\Frontend\Typolink\PageLinkBuilder\generateUrlForPageWithSiteConfiguration(), and TYPO3\CMS\Frontend\Middleware\StaticRouteResolver\getPageUri().

◆ resolveBaseWithVariants()

foreach ( $configuration[ 'languages'] as $languageConfiguration) foreach ( $configuration[ 'errorHandling'] ??[] as $errorHandlingConfiguration) string TYPO3\CMS\Core\Site\Entity\Site::resolveBaseWithVariants ( string  $baseUrl,
?array  $baseVariants 
)
protected

Checks if the base has variants, and takes the first variant which matches an expression.

Parameters
string$baseUrl
array | null$baseVariants
Returns
‪string

Definition at line 150 of file Site.php.

References TYPO3\CMS\Core\Site\Entity\Site\$baseUrl.

◆ sanitizeBaseUrl()

string TYPO3\CMS\Core\Site\Entity\Site::sanitizeBaseUrl ( string  $base)
protected

If a site base contains "/" or "www.domain.com", it is ensured that parse_url() can handle this kind of configuration properly.

Parameters
string$base
Returns
‪string

Definition at line 344 of file Site.php.

References TYPO3\CMS\Core\Site\Entity\Site\$base.

Member Data Documentation

◆ $availableLanguages

return TYPO3\CMS\Core\Site\Entity\Site::$availableLanguages

Definition at line 279 of file Site.php.

◆ $base

UriInterface TYPO3\CMS\Core\Site\Entity\Site::$base
protected

◆ $baseUrl

TYPO3\CMS\Core\Site\Entity\Site::$baseUrl
Initial value:
‪$configuration['base'] ?? '',
‪$configuration['baseVariants'] ?? null
)

Definition at line 97 of file Site.php.

Referenced by TYPO3\CMS\Core\Site\Entity\Site\resolveBaseWithVariants().

◆ $configuration [1/2]

array TYPO3\CMS\Core\Site\Entity\Site::$configuration
protected

Any attributes for this site

Definition at line 62 of file Site.php.

Referenced by TYPO3\CMS\Core\Site\Entity\Site\getConfiguration().

◆ $configuration [2/2]

TYPO3\CMS\Core\Site\Entity\Site::$configuration[ 'languages']
Initial value:
= !empty(‪$configuration['languages']) ? ‪$configuration['languages'] : [
0 => [
'languageId' => 0,
'title' => 'Default',
'navigationTitle' => '',
'typo3Language' => 'default',
'flag' => 'us',
'locale' => 'en_US.UTF-8',
'iso-639-1' => 'en',
'hreflang' => 'en-US',
'direction' => '',
],
]

Definition at line 84 of file Site.php.

◆ $identifier

string TYPO3\CMS\Core\Site\Entity\Site::$identifier
protected

Definition at line 49 of file Site.php.

Referenced by TYPO3\CMS\Core\Site\Entity\Site\getIdentifier().

◆ $rootPageId

int TYPO3\CMS\Core\Site\Entity\Site::$rootPageId
protected

Definition at line 57 of file Site.php.

Referenced by TYPO3\CMS\Core\Site\Entity\Site\getRootPageId().

◆ base

$this TYPO3\CMS\Core\Site\Entity\Site::base = new Uri($this->sanitizeBaseUrl($baseUrl))

Definition at line 101 of file Site.php.

◆ configuration

$this TYPO3\CMS\Core\Site\Entity\Site::configuration = $configuration

Definition at line 83 of file Site.php.

Referenced by TYPO3\CMS\Core\Site\Entity\Site\getAttribute().

◆ ERRORHANDLER_TYPE_FLUID

const TYPO3\CMS\Core\Site\Entity\Site::ERRORHANDLER_TYPE_FLUID = 'Fluid'
protected

Definition at line 44 of file Site.php.

Referenced by TYPO3\CMS\Core\Site\Entity\Site\getErrorHandler().

◆ ERRORHANDLER_TYPE_PAGE

const TYPO3\CMS\Core\Site\Entity\Site::ERRORHANDLER_TYPE_PAGE = 'Page'
protected

Definition at line 43 of file Site.php.

Referenced by TYPO3\CMS\Core\Site\Entity\Site\getErrorHandler().

◆ ERRORHANDLER_TYPE_PHP

const TYPO3\CMS\Core\Site\Entity\Site::ERRORHANDLER_TYPE_PHP = 'PHP'
protected

Definition at line 45 of file Site.php.

Referenced by TYPO3\CMS\Core\Site\Entity\Site\getErrorHandler().

◆ identifier

array<LanguageRef, $languages; protected array $errorHandlers; public function __construct(string $identifier, int $rootPageId, array $configuration) { $this-> TYPO3\CMS\Core\Site\Entity\Site::identifier = $identifier
protected

SiteLanguage>

Definition at line 81 of file Site.php.

Referenced by TYPO3\CMS\Core\Site\Entity\Site\getAttribute().

◆ languages

array<LanguageRef, function getLanguages(): array { $languages = []; foreach ($this->languages as $languageId => $language) { if ($language->enabled()) { $languages[$languageId] = $language; } } return $languages; } public array<LanguageRef, function getAllLanguages(): array { return $this->languages; } public SiteLanguage function getLanguageById(int $languageId): SiteLanguage { if (isset($this->languages[$languageId])) { return $this-> TYPO3\CMS\Core\Site\Entity\Site::languages[ $languageId]

Returns all available languages of this site

Returns
‪array<LanguageRef, SiteLanguage>

Definition at line 240 of file Site.php.

Referenced by TYPO3\CMS\Core\Site\Entity\Site\getDefaultLanguage().

◆ rootPageId

$this TYPO3\CMS\Core\Site\Entity\Site::rootPageId = $rootPageId

Definition at line 82 of file Site.php.

‪TYPO3\CMS\Core\Site\Entity\Site\resolveBaseWithVariants
‪foreach($configuration['languages'] as $languageConfiguration) foreach($configuration['errorHandling'] ??[] as $errorHandlingConfiguration) string resolveBaseWithVariants(string $baseUrl, ?array $baseVariants)
Definition: Site.php:150
‪TYPO3\CMS\Core\Site\Entity\Site\$configuration
‪array $configuration
Definition: Site.php:62