TemplateService

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

Tags
see
TypoScriptParser
see
AbstractConditionMatcher

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_config_BRP  : mixed
$ext_constants_BRP  : mixed
$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<string|int, mixed>
The rootline from current page to the root page
$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<string|int, mixed>
Rootline all the way to the root. Set but runThroughTemplates
$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
addExtensionStatics()  : mixed
Adds the default TypoScript files for extensions if any.
generateConfig()  : mixed
Generates the configuration array by replacing constants and parsing the whole thing.
getCurrentPageData()  : array<string|int, mixed>
Fetches the "currentPageData" array from cache
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
updateRootlineData()  : mixed
This function can be used to update the data of the current rootLine e.g. when a different language is used.
addDefaultTypoScript()  : mixed
Adds the TypoScript from the global array.
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
versionOL()  : mixed
Creating versioning overlay of a sys_template record.

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_config_BRP

Deprecated

Unused since v11, will be removed in v12

public mixed $ext_config_BRP = 0

$ext_constants_BRP

Deprecated

Unused since v11, will be removed in v12

public mixed $ext_constants_BRP = 0

$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

The rootline from current page to the root page

public array<string|int, mixed> $rootLine

$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 all the way to the root. Set but runThroughTemplates

protected array<string|int, mixed> $absoluteRootLine

$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

addExtensionStatics()

Adds the default TypoScript files for extensions if any.

public 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()

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()

getCurrentPageData()

Fetches the "currentPageData" array from cache

public getCurrentPageData(int $pageId, string $mountPointValue) : array<string|int, mixed>

NOTE about currentPageData: It holds information about the TypoScript conditions along with the list of template uid's which is used on the page. In the getFromCache() function in TSFE, currentPageData is used to evaluate if there is a template and if the matching conditions are alright. Unfortunately this does not take into account if the templates in the rowSum of currentPageData has changed composition, eg. due to hidden fields or start/end time. So if a template is hidden or times out, it'll not be discovered unless the page is regenerated - at least the this->start function must be called, because this will make a new portion of data in currentPageData string.

Parameters
$pageId : int
$mountPointValue : string
Internal
Tags
throws
NoSuchCacheException
Return values
array<string|int, mixed>

Returns the unmatched array $currentPageData if found cached in "cache_pagesection". Otherwise FALSE is returned which means that the array must be generated and stored in the cache

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)

Tags
see
TypoScriptFrontendController::getConfigArray()

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
Tags
see
substituteConstants()
Return values
string

Replacement

updateRootlineData()

This function can be used to update the data of the current rootLine e.g. when a different language is used.

public updateRootlineData(array<string|int, mixed> $fullRootLine) : mixed

This function must not be used if there are different pages in the rootline as before!

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

Array containing the FULL rootline (up to the TYPO3 root)

Tags
throws
RuntimeException

If the given $fullRootLine does not contain all pages that are in the current template rootline

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

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.

versionOL()

Creating versioning overlay of a sys_template record.

protected versionOL(array<string|int, mixed> &$row) : mixed
Parameters
$row : array<string|int, mixed>

Row to overlay (passed by reference)


        
On this page

Search results