TemplateService

Template object that is responsible for generating the TypoScript template based on template records.

Deprecated

This class should not be used anymore, last core usages will be removed during v12. Using methods or properties of this class will start logging deprecation messages.

Table of Contents

Properties

$clearList_const  : array<string|int, string>
Used by Backend only (Typoscript Template Analyzer)
$clearList_setup  : array<string|int, mixed>
Used by Backend only (Typoscript Template Analyzer)
$config  : array<string|int, mixed>
For fetching TypoScript code from template hierarchy before parsing it.
$constants  : array<string|int, mixed>
Constant field
$ext_regComments  : bool
$ext_regLinenumbers  : bool
$flatSetup  : array<string|int, mixed>
$hierarchyInfo  : array<string|int, mixed>
For Template Analyzer in backend
$loaded  : bool
Set, if the TypoScript template structure is loaded and OK, see ->start()
$matchAlternative  : array<string|int, mixed>
This array is passed on to matchObj by generateConfig().
$parserErrors  : array<string|int, mixed>
$rootLine  : array<int, array<string, mixed>>
This is the "local" rootline of a deep page that stops at the first parent sys_template record that has "root" flag set, in natural parent-child order.
$sections  : array<string|int, mixed>|null
Tracking all conditions found during parsing of TypoScript. Used for the "all" key in currentPageData
$setup  : array<string|int, mixed>
$setup_constants  : array<string|int, mixed>
$tt_track  : bool
If set, the global tt-timeobject is used to log the performance.
$absoluteRootLine  : array<int, array<string, mixed>>
Rootline of page records all the way to the root.
$context  : Context
$extensionStaticsProcessed  : bool
Indicator that extension statics are processed.
$frontendController  : TypoScriptFrontendController|null
$hierarchyInfoToRoot  : array<string|int, mixed>
For Template Analyzer in backend (setup content only)
$isDefaultTypoScriptAdded  : bool
Set to TRUE after the default TypoScript was added during parsing.
$matchAll  : bool
If set, the match-class matches everything! Used for backend modules only. Never frontend!
$packageManager  : PackageManager
$processExtensionStatics  : bool
Trigger value, to ensure that extension statics are processed.
$processIncludesHasBeenRun  : bool
Set to TRUE after $this->config and $this->constants have processed all <INCLUDE_TYPOSCRIPT:> instructions.
$queryBuilderRestrictions  : AbstractRestrictionContainer
Contains the restrictions about deleted, and some frontend related topics
$rootId  : int
The Page UID of the root page
$rowSum  : array<string|int, mixed>
Array of arrays with title/uid of templates in hierarchy
$sectionsMatch  : array<string|int, mixed>
Tracking all matching conditions found
$simulationHiddenOrTime  : bool
Set if preview of some kind is enabled.
$templateIncludePaths  : array<string|int, mixed>
Holds the include paths of the templates (empty if from database)
$verbose  : bool
option to enable logging, time-tracking (FE-only) usually, this is only done when - in FE a BE_USER is logged-in - in BE when the BE_USER needs information about the template (TypoScript module)

Methods

__construct()  : mixed
generateConfig()  : mixed
Generates the configuration array by replacing constants and parsing the whole thing.
getProcessExtensionStatics()  : bool
getRootId()  : int
Returns the page ID of the rootlevel
getRootlineLevel()  : int
Returns the level of the given page in the rootline - Multiple pages can be given by separating the UIDs by comma.
includeStaticTypoScriptSources()  : mixed
Includes static template files (from extensions) for the input template record row.
matching()  : array<string|int, mixed>
Fetches data about which TypoScript-matches there are at this page. Then it performs a matchingtest.
processTemplate()  : mixed
Checks if the template ($row) has some included templates and after including them it fills the arrays with the setup Builds up $this->rowSum
runThroughTemplates()  : mixed
Traverses the rootLine from the root and out. For each page it checks if there is a template record. If there is a template record, $this->processTemplate() is called.
setProcessExtensionStatics()  : mixed
setVerbose()  : mixed
sets the verbose parameter
start()  : mixed
This is all about fetching the right TypoScript template structure. If it's not cached then it must be generated and cached! The method traverses the rootline structure from out to in, fetches the hierarchy of template records and based on this either finds the cached TypoScript template structure or parses the template and caches it for next time.
substituteConstantsCallBack()  : string
Call back method for preg_replace_callback in substituteConstants
addDefaultTypoScript()  : mixed
Adds the TypoScript from the global array.
addExtensionStatics()  : mixed
Adds the default TypoScript files for extensions if any.
getCacheEntry()  : mixed
Returns data stored for the hash string in the cache "cache_hash" used to store the parsed TypoScript template structures.
getTimeTracker()  : TimeTracker
getTypoScriptFrontendController()  : TypoScriptFrontendController|null
getTypoScriptSourceFileContent()  : string
Retrieves the content of the first existing file by extension order.
initializeDatabaseQueryRestrictions()  : mixed
Set up the query builder restrictions, optionally include hidden records
prependStaticExtra()  : array<string|int, mixed>
Appends (not prepends) additional TypoScript code to static template records/files as set in TYPO3_CONF_VARS For files the "uid" value is the extension key but with any underscores removed. Possibly with a path if its a static file selected in the template record
processIncludes()  : mixed
Searching TypoScript code text (for constants and config (Setup)) for include instructions and does the inclusion of external TypoScript files if needed.
setCacheEntry()  : mixed
Stores $data in the 'hash' cache with the hash key $identifier
substituteConstants()  : string
Substitutes the constants from $this->flatSetup in the text string $all

Properties

$clearList_const

Used by Backend only (Typoscript Template Analyzer)

public array<string|int, string> $clearList_const = []

$clearList_setup

Used by Backend only (Typoscript Template Analyzer)

public array<string|int, mixed> $clearList_setup = []

$config

For fetching TypoScript code from template hierarchy before parsing it.

public array<string|int, mixed> $config = []

Each array contains code field values from template records/files: Setup field

$constants

Constant field

public array<string|int, mixed> $constants = []

$ext_regComments

public bool $ext_regComments = false

$ext_regLinenumbers

public bool $ext_regLinenumbers = false

$flatSetup

public array<string|int, mixed> $flatSetup = []

$hierarchyInfo

For Template Analyzer in backend

public array<string|int, mixed> $hierarchyInfo = []

$loaded

Set, if the TypoScript template structure is loaded and OK, see ->start()

public bool $loaded = false

$matchAlternative

This array is passed on to matchObj by generateConfig().

public array<string|int, mixed> $matchAlternative = []

If it holds elements, they are used for matching instead. See comment at the match-class. Used for backend modules only. Never frontend!

Internal

$parserErrors

public array<string|int, mixed> $parserErrors = []

$rootLine

This is the "local" rootline of a deep page that stops at the first parent sys_template record that has "root" flag set, in natural parent-child order.

public array<int, array<string, mixed>> $rootLine

In frontend context, this is also set as TSFE TypoScriptFrontendController->config['rootLine'].

Both language and version overlays are applied to these page records: All "data" fields are set to language / version overlay values, except uid and pid, which are the default-language and live-version ids.

When page uid 5 is called in this example: [0] Project name |- [2] An organizational page, probably with is_siteroot=1 and a site config |- [3] Site root with a sys_template having "root" flag set |- [5] Here you are

This $rootLine is: [0] => [uid = 3, pid = 2, title = Site root with a sys_template having "root" flag set, ...] [1] => [uid = 5, pid = 3, title = Here you are, ...]

$sections

Tracking all conditions found during parsing of TypoScript. Used for the "all" key in currentPageData

public array<string|int, mixed>|null $sections

$setup

public array<string|int, mixed> $setup = []

Contains TypoScript setup part after parsing

$setup_constants

public array<string|int, mixed> $setup_constants = []

$tt_track

If set, the global tt-timeobject is used to log the performance.

public bool $tt_track = true

$absoluteRootLine

Rootline of page records all the way to the root.

protected array<int, array<string, mixed>> $absoluteRootLine = []

In frontend context, this is also set as TSFE TypoScriptFrontendController->rootLine.

Both language and version overlays are applied to these page records: All "data" fields are set to language / version overlay values, except uid and pid, which are the default-language and live-version ids.

First array row with the highest key is the deepest page (the requested page), then parent pages with descending keys until (but not including) the project root pseudo page 0.

When page uid 5 is called in this example: [0] Project name |- [2] An organizational page, probably with is_siteroot=1 and a site config |- [3] Site root with a sys_template having "root" flag set |- [5] Here you are

This $absoluteRootLine is: [3] => [uid = 5, pid = 3, title = Here you are, ...] [2] => [uid = 3, pid = 2, title = Site root with a sys_template having "root" flag set, ...] [1] => [uid = 2, pid = 0, title = An organizational page, probably with is_siteroot=1 and a site config, ...]

$extensionStaticsProcessed

Indicator that extension statics are processed.

protected bool $extensionStaticsProcessed = false

These files are considered if either a root template has been processed or the $processExtensionStatics property has been set to TRUE.

$hierarchyInfoToRoot

For Template Analyzer in backend (setup content only)

protected array<string|int, mixed> $hierarchyInfoToRoot = []

$isDefaultTypoScriptAdded

Set to TRUE after the default TypoScript was added during parsing.

protected bool $isDefaultTypoScriptAdded = false

This prevents double inclusion of the same TypoScript code.

Tags
see
addDefaultTypoScript()

$matchAll

If set, the match-class matches everything! Used for backend modules only. Never frontend!

protected bool $matchAll = false

$processExtensionStatics

Trigger value, to ensure that extension statics are processed.

protected bool $processExtensionStatics = false

$processIncludesHasBeenRun

Set to TRUE after $this->config and $this->constants have processed all <INCLUDE_TYPOSCRIPT:> instructions.

protected bool $processIncludesHasBeenRun = false

This prevents double processing of INCLUDES.

Tags
see
processIncludes()

$rootId

The Page UID of the root page

protected int $rootId

$rowSum

Array of arrays with title/uid of templates in hierarchy

protected array<string|int, mixed> $rowSum

$sectionsMatch

Tracking all matching conditions found

protected array<string|int, mixed> $sectionsMatch

$simulationHiddenOrTime

Set if preview of some kind is enabled.

protected bool $simulationHiddenOrTime = false

$templateIncludePaths

Holds the include paths of the templates (empty if from database)

protected array<string|int, mixed> $templateIncludePaths = []

$verbose

option to enable logging, time-tracking (FE-only) usually, this is only done when - in FE a BE_USER is logged-in - in BE when the BE_USER needs information about the template (TypoScript module)

protected bool $verbose = false

Methods

generateConfig()

Generates the configuration array by replacing constants and parsing the whole thing.

public generateConfig() : mixed

Depends on $this->config and $this->constants to be set prior to this! (done by processTemplate/runThroughTemplates)

Tags
see
TypoScriptParser
see
start()

getProcessExtensionStatics()

public getProcessExtensionStatics() : bool
Return values
bool

getRootId()

Returns the page ID of the rootlevel

public getRootId() : int
Return values
int

getRootlineLevel()

Returns the level of the given page in the rootline - Multiple pages can be given by separating the UIDs by comma.

public getRootlineLevel(string $list) : int
Parameters
$list : string

A list of UIDs for which the rootline-level should get returned

Return values
int

The level in the rootline. If more than one page was given the lowest level will get returned.

includeStaticTypoScriptSources()

Includes static template files (from extensions) for the input template record row.

public includeStaticTypoScriptSources(string $idList, string $templateID, int $pid, array<string|int, mixed> $row) : mixed
Parameters
$idList : string

A list of already processed template ids including the current; The list is on the form "[prefix][uid]" where [prefix] is "sys" for "sys_template" records and "ext" for static include files (from extensions). The list is used to check that the recursive inclusion of templates does not go into circles: Simply it is used to NOT include a template record/file which has already BEEN included somewhere in the recursion.

$templateID : string

The id of the current template. Same syntax as $idList ids, eg. "sys_123

$pid : int

The PID of the input template record

$row : array<string|int, mixed>

A full TypoScript template record

Internal
Tags
see
processTemplate()

matching()

Fetches data about which TypoScript-matches there are at this page. Then it performs a matchingtest.

public matching(array<string|int, mixed> $cc) : array<string|int, mixed>
Parameters
$cc : array<string|int, mixed>

An array with three keys, "all", "rowSum" and "rootLine" - all coming from the "currentPageData" array

Return values
array<string|int, mixed>

The input array but with a new key added, "match" which contains the items from the "all" key which when passed to tslib_matchCondition returned TRUE.

processTemplate()

Checks if the template ($row) has some included templates and after including them it fills the arrays with the setup Builds up $this->rowSum

public processTemplate(array<string|int, mixed> $row, string $idList, int $pid[, string $templateID = '' ][, string $templateParent = '' ][, string $includePath = '' ]) : mixed
Parameters
$row : array<string|int, mixed>

A full TypoScript template record (sys_template/forged "dummy" record made from static template file)

$idList : string

A list of already processed template ids including the current; The list is on the form "[prefix][uid]" where [prefix] is "sys" for "sys_template" records, records and "ext" for static include files (from extensions). The list is used to check that the recursive inclusion of templates does not go into circles: Simply it is used to NOT include a template record/file which has already BEEN included somewhere in the recursion.

$pid : int

The PID of the input template record

$templateID : string = ''

The id of the current template. Same syntax as $idList ids, eg. "sys_123

$templateParent : string = ''

Parent template id (during recursive call); Same syntax as $idList ids, eg. "sys_123

$includePath : string = ''

Specifies the path from which the template was included (used with static_includes)

Tags
see
runThroughTemplates()

runThroughTemplates()

Traverses the rootLine from the root and out. For each page it checks if there is a template record. If there is a template record, $this->processTemplate() is called.

public runThroughTemplates(array<string|int, mixed> $theRootLine[, int $start_template_uid = 0 ]) : mixed

Resets and affects internal variables like $this->constants, $this->config and $this->rowSum Also creates $this->rootLine which is a root line stopping at the root template (contrary to $this->getTypoScriptFrontendController()->rootLine which goes all the way to the root of the tree

Parameters
$theRootLine : array<string|int, mixed>

The rootline of the current page (going ALL the way to tree root)

$start_template_uid : int = 0

Set specific template record UID to select; this is only for debugging/development/analysis use in backend modules like "Web > Template". For parsing TypoScript templates in the frontend it should be 0 (zero)

Tags
see
start()

setProcessExtensionStatics()

public setProcessExtensionStatics(bool $processExtensionStatics) : mixed
Parameters
$processExtensionStatics : bool

setVerbose()

sets the verbose parameter

public setVerbose(bool $verbose) : mixed
Parameters
$verbose : bool

start()

This is all about fetching the right TypoScript template structure. If it's not cached then it must be generated and cached! The method traverses the rootline structure from out to in, fetches the hierarchy of template records and based on this either finds the cached TypoScript template structure or parses the template and caches it for next time.

public start(array<string|int, mixed> $theRootLine) : mixed

Sets $this->setup to the parsed TypoScript template array

Parameters
$theRootLine : array<string|int, mixed>

The rootline of the current page (going ALL the way to tree root)

substituteConstantsCallBack()

Call back method for preg_replace_callback in substituteConstants

public substituteConstantsCallBack(array<string|int, mixed> $matches) : string
Parameters
$matches : array<string|int, mixed>

Regular expression matches

Internal
Return values
string

Replacement

addDefaultTypoScript()

Adds the TypoScript from the global array.

protected addDefaultTypoScript() : mixed

The class property isDefaultTypoScriptAdded ensures that the adding only happens once.

Tags
see
isDefaultTypoScriptAdded

addExtensionStatics()

Adds the default TypoScript files for extensions if any.

protected addExtensionStatics(string $idList, string $templateID, int $pid) : mixed
Parameters
$idList : string

A list of already processed template ids including the current; The list is on the form "[prefix][uid]" where [prefix] is "sys" for "sys_template" records and "ext" for static include files (from extensions). The list is used to check that the recursive inclusion of templates does not go into circles: Simply it is used to NOT include a template record/file which has already BEEN included somewhere in the recursion.

$templateID : string

The id of the current template. Same syntax as $idList ids, eg. "sys_123

$pid : int

The PID of the input template record

Internal
Tags
see
includeStaticTypoScriptSources()

getCacheEntry()

Returns data stored for the hash string in the cache "cache_hash" used to store the parsed TypoScript template structures.

protected getCacheEntry(string $identifier) : mixed
Parameters
$identifier : string

The hash-string which was used to store the data value

Return values
mixed

The data from the cache

getTypoScriptSourceFileContent()

Retrieves the content of the first existing file by extension order.

protected getTypoScriptSourceFileContent(string $filePath, string $baseName) : string

Returns the empty string if no file is found.

Parameters
$filePath : string

The location of the file.

$baseName : string

The base file name. "constants" or "setup".

Return values
string

initializeDatabaseQueryRestrictions()

Set up the query builder restrictions, optionally include hidden records

protected initializeDatabaseQueryRestrictions() : mixed

prependStaticExtra()

Appends (not prepends) additional TypoScript code to static template records/files as set in TYPO3_CONF_VARS For files the "uid" value is the extension key but with any underscores removed. Possibly with a path if its a static file selected in the template record

protected prependStaticExtra(array<string|int, mixed> $subrow) : array<string|int, mixed>
Parameters
$subrow : array<string|int, mixed>

Static template record/file

Tags
see
addExtensionStatics()
see
includeStaticTypoScriptSources()
Return values
array<string|int, mixed>

Returns the input array where the values for keys "config" and "constants" may have been modified with prepended code.

processIncludes()

Searching TypoScript code text (for constants and config (Setup)) for include instructions and does the inclusion of external TypoScript files if needed.

protected processIncludes() : mixed
Tags
see
TypoScriptParser
see
generateConfig()

setCacheEntry()

Stores $data in the 'hash' cache with the hash key $identifier

protected setCacheEntry(string $identifier, mixed $data, string $tag) : mixed
Parameters
$identifier : string

32 bit hash string (eg. a md5 hash of a serialized array identifying the data being stored)

$data : mixed

The data to store

$tag : string

Is just a textual identification in order to inform about the content

substituteConstants()

Substitutes the constants from $this->flatSetup in the text string $all

protected substituteConstants(string $all) : string
Parameters
$all : string

TypoScript code text string

Tags
see
generateConfig()
Return values
string

The processed string with all constants found in $this->flatSetup as key/value pairs substituted.


        
On this page

Search results