Site

The site request attribute hold information about the current site in the object \TYPO3\CMS\Core\Site\Entity\Site. It is available in frontend and backend context.

Example:

$site = $request->getAttribute('site');
$siteConfiguration = $site->getConfiguration();

Note

In backend context the attribute can hold a \TYPO3\CMS\Core\Site\Entity\NullSite object when the module does not provide a page tree or no page in the page tree is selected.

API

class TYPO3\CMS\Core\Site\Entity\Site

Entity representing a single site with available languages

getIdentifier()

Gets the identifier of this site, mainly used when maintaining / configuring sites.

Return type

string

getBase()

Returns the base URL of this site

Return type

Psr\Http\Message\UriInterface

getRootPageId()

Returns the root page ID of this site

Return type

int

getLanguages()
Return type

array

getAllLanguages()
Return type

array

getLanguageById(int $languageId)

Returns a language of this site, given by the sys_language_uid

Parameters
  • $languageId (int) -- the languageId

Return type

TYPO3\CMS\Core\Site\Entity\SiteLanguage

getDefaultLanguage()
Return type

TYPO3\CMS\Core\Site\Entity\SiteLanguage

getAvailableLanguages(TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication $user, bool $includeAllLanguagesFlag = false, int $pageId = NULL)
Parameters
  • $user (TYPO3\CMS\Core\Authentication\BackendUserAuthentication) -- the user

  • $includeAllLanguagesFlag (bool) -- the includeAllLanguagesFlag, default: false

  • $pageId (int) -- the pageId, default: NULL

Return type

array

getErrorHandler(int $statusCode)

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

Parameters
  • $statusCode (int) -- the statusCode

Return type

TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface

getConfiguration()

Returns the whole configuration for this site

Return type

array

getSettings()
Return type

TYPO3\CMS\Core\Site\Entity\SiteSettings

getAttribute(string $attributeName)

Returns a single configuration attribute

Parameters
  • $attributeName (string) -- the attributeName

getRouter(TYPO3\\CMS\\Core\\Context\\Context $context = NULL)

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

Parameters
  • $context (TYPO3\CMS\Core\Context\Context) -- the context, default: NULL

Return type

TYPO3\CMS\Core\Routing\RouterInterface