FrontendTypoScript

final class \TYPO3\CMS\Core\TypoScript\FrontendTypoScript

This class contains the TypoScript set up by the PrepareTypoScriptFrontendRendering Frontend middleware. It can be accessed in content objects:

$frontendTypoScript = $request->getAttribute('frontend.typoscript');

Table of Contents

Methods

__construct()  : mixed
getFlatSettings()  : array
This is *always* set up by the middleware: Current settings (aka "TypoScript constants") are needed for page cache identifier calculation.
getSettingsTree()  : RootNode
getSetupArray()  : array
The full Frontend TypoScript array.
getSetupTree()  : RootNode
hasSetup()  : bool
When a page is retrieved from cache and does not contain COA_INT or USER_INT objects, Frontend TypoScript setup is not calculated, so the AST and the array are not set.
setSetupArray()  : void
setSetupTree()  : void

Methods

__construct()

public __construct(RootNode $settingsTree, array $flatSettings) : mixed

Parameters

$settingsTree : RootNode
$flatSettings : array

getFlatSettings()

This is *always* set up by the middleware: Current settings (aka "TypoScript constants") are needed for page cache identifier calculation.

public getFlatSettings() : array

This is a "flattened" array of all settings, as example, consider these settings TypoScript:

mySettings {
    foo = fooValue
    bar = barValue
}

This will result in this array:

$flatSettings = [
    'mySettings.foo' => 'fooValue',
    'mySettings.bar' => 'barValue',
];

Return values

array

getSettingsTree()

public getSettingsTree() : RootNode

Return values

RootNode

getSetupArray()

The full Frontend TypoScript array.

public getSetupArray() : array

This is always set up as soon as the Frontend rendering needs to actually render something and can not get the full content from page cache. This is the case when a page cache entry does not exist, or when the page contains COA_INT or USER_INT objects.

Return values

array

getSetupTree()

public getSetupTree() : RootNode

Return values

RootNode

hasSetup()

When a page is retrieved from cache and does not contain COA_INT or USER_INT objects, Frontend TypoScript setup is not calculated, so the AST and the array are not set.

public hasSetup() : bool

Calling getSetupTree() or getSetupArray() will then throw an exception.

To avoid the exception, consumers can call hasSetup() beforehand.

Note casual content objects do not need to do this, since setup TypoScript is always set up when content objects need to be calculated.

Return values

bool

setSetupArray()

public setSetupArray(array $setupArray) : void

Parameters

$setupArray : array
On this page