‪TYPO3CMS  10.4
TYPO3\CMS\Core\Context\LanguageAspect Class Reference
Inheritance diagram for TYPO3\CMS\Core\Context\LanguageAspect:
TYPO3\CMS\Core\Context\AspectInterface

Public Member Functions

 __construct (int $id=0, int $contentId=null, string $overlayType=self::OVERLAYS_ON_WITH_FLOATING, array $fallbackChain=[])
 
string getOverlayType ()
 
int getId ()
 
int getContentId ()
 
 getFallbackChain ()
 
bool doOverlays ()
 
string getLegacyLanguageMode ()
 
string getLegacyOverlayType ()
 
int string array get (string $name)
 

Public Attributes

const OVERLAYS_OFF = 'off'
 
const OVERLAYS_MIXED = 'mixed'
 
const OVERLAYS_ON = 'on'
 
const OVERLAYS_ON_WITH_FLOATING = 'includeFloating'
 

Protected Attributes

int $id = 0
 
int $contentId = 0
 
array $fallbackChain = array( )
 
string $overlayType
 

Detailed Description

The Aspect is usually available as "language" property, and can be used to find out the "overlay"/data retrieval strategy.

"id" (languageId, int)

  • ‪formally known as $TSFE->sys_language_uid
  • ‪the requested language of the current page (frontend)
  • ‪used in menus and links to generate "links in language with this ID"

"contentId" (int)

  • ‪formally known as $TSFE->sys_language_content
  • ‪the language of records to be fetched
  • ‪if empty, "languageId" is used.

"fallbackChain"

  • ‪when "fallback" go with
  • ‪depends what "contentId" value should be set
  • ‪defined in config.sys_language_mode (strict/content_fallback:4,5,stop/ignore?)
  • ‪previously known as $TSFE->sys_language_mode
  • ‪defines "contentId" based on "if the current page is available in this language"
    • ‪"strict"
    • ‪"fallback" if current page is not available, check the fallbackChain" - "fallbackAndIgnore"

"overlayType"

  • ‪defines which way the records should be fetched from ($TSFE->sys_language_contentOL and config.sys_language_overlay)
  • ‪usually you fetch language 0 and -1, then take the "contentId" and "overlay" them
    • ‪here you have two choices
      1. ‪"on" if there is no overlay, do not render the default language records ("hideNonTranslated")
      2. ‪"mixed" - if there is no overlay, just keep the default language, possibility to have mixed languages - config.sys_language_overlay = 1
      3. ‪"off" - do not do overlay, only fetch records available in the current "contentId" (see above), and do not care about overlays or fallbacks - fallbacks could be an option here, actually that is placed on top
      4. ‪"includeFloating" - on + includeRecordsWithoutDefaultTranslation

Definition at line 56 of file LanguageAspect.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Context\LanguageAspect::__construct ( int  $id = 0,
int  $contentId = null,
string  $overlayType = self::OVERLAYS_ON_WITH_FLOATING,
array  $fallbackChain = [] 
)

Create the default language

Parameters
int$id
int | null$contentId
string$overlayType
array$fallbackChain

Definition at line 87 of file LanguageAspect.php.

References TYPO3\CMS\Core\Context\LanguageAspect\$contentId, TYPO3\CMS\Core\Context\LanguageAspect\$fallbackChain, TYPO3\CMS\Core\Context\LanguageAspect\$id, and TYPO3\CMS\Core\Context\LanguageAspect\$overlayType.

Member Function Documentation

◆ doOverlays()

bool TYPO3\CMS\Core\Context\LanguageAspect::doOverlays ( )

Whether overlays should be done

Returns
‪bool

Definition at line 138 of file LanguageAspect.php.

References TYPO3\CMS\Core\Context\LanguageAspect\OVERLAYS_OFF.

◆ get()

int string array TYPO3\CMS\Core\Context\LanguageAspect::get ( string  $name)

◆ getContentId()

int TYPO3\CMS\Core\Context\LanguageAspect::getContentId ( )

Contains the language UID of the content records that should be overlaid to would be fetched. This is especially useful when a page requested with language=4 should fall back to showing content of language=2 (see fallbackChain)

Returns
‪int

Definition at line 123 of file LanguageAspect.php.

References TYPO3\CMS\Core\Context\LanguageAspect\$contentId.

◆ getFallbackChain()

TYPO3\CMS\Core\Context\LanguageAspect::getFallbackChain ( )

◆ getId()

int TYPO3\CMS\Core\Context\LanguageAspect::getId ( )

Returns the language ID the current page was requested, this is relevant when building menus or links to other pages.

Returns
‪int

Definition at line 111 of file LanguageAspect.php.

References TYPO3\CMS\Core\Context\LanguageAspect\$id.

Referenced by TYPO3\CMS\IndexedSearch\Hook\TypoScriptFrontendHook\initializeIndexerConfiguration(), and TYPO3\CMS\Core\Domain\Repository\PageRepository\isPageSuitableForLanguage().

◆ getLegacyLanguageMode()

string TYPO3\CMS\Core\Context\LanguageAspect::getLegacyLanguageMode ( )

Previously known as TSFE->sys_language_mode, here for compatibility reasons

Returns
‪string

Definition at line 148 of file LanguageAspect.php.

Referenced by TYPO3\CMS\Core\Context\LanguageAspect\get().

◆ getLegacyOverlayType()

string TYPO3\CMS\Core\Context\LanguageAspect::getLegacyOverlayType ( )

◆ getOverlayType()

string TYPO3\CMS\Core\Context\LanguageAspect::getOverlayType ( )

Used language overlay

Returns
‪string

Definition at line 100 of file LanguageAspect.php.

References TYPO3\CMS\Core\Context\LanguageAspect\$overlayType.

Member Data Documentation

◆ $contentId

int TYPO3\CMS\Core\Context\LanguageAspect::$contentId = 0
protected

◆ $fallbackChain

array TYPO3\CMS\Core\Context\LanguageAspect::$fallbackChain = array( )
protected

◆ $id

int TYPO3\CMS\Core\Context\LanguageAspect::$id = 0
protected

◆ $overlayType

string TYPO3\CMS\Core\Context\LanguageAspect::$overlayType
protected

◆ OVERLAYS_MIXED

◆ OVERLAYS_OFF

◆ OVERLAYS_ON

◆ OVERLAYS_ON_WITH_FLOATING