Feature: #98914 - TypoScript as request attribute
See forge#98914
Description
The TYPO3 frontend middleware chain now sets up the request
attribute
frontend.
. This is an instance of
\TYPO3\
and contains
the calculated TypoScript
settings
(formerly "constants") and
sometimes
setup
, depending on page cache status.
When a content object or plugin (plugins are content objects as well) needs the current TypoScript, it can retrieve it using this API:
// New substitution of $GLOBALS['TSFE']->tmpl->setup
$frontendTypoScriptSetupArray = $request->getAttribute('frontend.typoscript')->getSetupArray();
The
Frontend
attribute contains some more getters:
-
get
: The TypoScript settings as object tree. This tree is still a bit experimental in TYPO3 v12 and should only be used if really needed for now, it may still change. It is marked internal at the moment.Settings Tree () The constants tree is always set up in frontend requests: It is needed early for page cache determination, content objects can expect it to be set.
-
get
: The TypoScript settings as flat array. Example TypoScript:Flat Settings () mySettings { foo = fooValue bar = barValue }
Copied!Result array:
$flatSettings = [ 'mySettings.foo' => 'fooValue', 'mySettings.bar' => 'barValue', ];
Copied!The settings array is always set up in frontend requests: It is needed early for page cache determination, content objects can expect it to be set.
-
get
: The TypoScript setup as object tree. This tree is still a bit experimental in TYPO3 v12 and should only be used if really needed for now, it may still change. It is marked internal at the moment.Setup Tree () The setup tree is only set up, if a frontend request could not be satisfied from page cache and a full page content calculation is required, or if a page cache does exist, but contains
USER_
orINT COA_
that have to be calculated for each call. Effectively, when a content object rendering is called, the object can expect the setup object tree to be set.INT -
get
: An array representation of the setup tree. This is identical to the oldSetup Array () TYPO3\
that was usually accessed usingCMS\ Core\ Typo Script\ Template Service->setup $GLOBALS
.['TSFE']->tmpl->setup This is the main API to retrieve frontend TypoScript for now. Content objects do receive the current request from the rendering chain and can retrieve the full TypoScript this way, if needed. Note that content objects also retrieve the "local" content object configuration already, an access to the full TypoScript in general is only needed in seldom cases.
The setup array is only set up if a frontend request could not be satisfied from page cache and a full page content calculation is required, or if a page cache does exist but contains
USER_
orINT COA_
that have to be calculated for each call. Effectively, when a content object rendering is called, the object can expect the setup object tree to be set.INT
Impact
This is a substitution especially of the deprecated
\TYPO3\
,
typical old calls were
Typo
or
$GLOBALS
,
often reading the
setup
property using
tmpl->setup
to grab the current TypoScript
setup array. These calls should be avoided, the
Template
and the
tmpl
property will be removed in TYPO3 v13.