TypoScriptFrontendController implements LoggerAwareInterface uses LoggerAwareTrait

Main controller class of the TypoScript based frontend.

Deprecated

since TYPO3 v13, will vanish during v14 development. There are some remaining internal usages that can be adapted without further .rst files. The class should vanish together with $GLOBALS['TSFE'] in v14.

This is prepared in Frontend middlewares and the content rendering is ultimately called in \TYPO3\CMS\Frontend\Http\RequestHandler.

When calling a Frontend page, an instance of this object is available as $GLOBALS['TSFE'], even though the core development strives to get rid of this in the future.

Table of Contents

Interfaces

LoggerAwareInterface

Properties

$absRefPrefix  : string
Absolute Reference prefix.
$additionalFooterData  : array<string|int, mixed>
Used to accumulate additional HTML-code for the footer-section of the template
$additionalHeaderData  : array<string|int, mixed>
Eg. insert JS-functions in this array ($additionalHeaderData) to include them once. Use associative keys.
$cacheGenerated  : int
$cObj  : ContentObjectRenderer
Page content render object.
$config  : array<string, mixed>
A central data array consisting of various keys, initialized and processed at various places in the class.
$content  : string
All page content is accumulated in this variable. See RequestHandler
$contentPid  : int
Available as @internal $request->getAttribute('frontend.page.information')->getContentFromPid().
$currentRecord  : string
This is set to the [table]:[uid] of the latest record rendered. Note that class ContentObjectRenderer has an equal value, but that is pointing to the record delivered in the $data-array of the ContentObjectRenderer instance, if the cObjects CONTENT or RECORD created that instance
$debugInformationHeader  : string|null
If debug mode is enabled, this contains the information if a page is fetched from cache, and sent as HTTP Response Header.
$id  : int
Use $request->getAttribute('frontend.page.information')->getId() instead.
$newHash  : string
This hash is unique to the page id, involved TS templates, TS condition verdicts, and some other parameters that influence page render result. Used to get/set page cache.
$page  : array<string|int, mixed>|null
Use $request->getAttribute('frontend.page.information')->getPageRecord() instead.
$pageContentWasLoadedFromCache  : bool
Set if cached content was fetched from the cache.
$recordRegister  : array<string|int, mixed>
Used by RecordContentObject and ContentContentObject to ensure the a records is NOT rendered twice through it!
$register  : array<string|int, mixed>
$registerStack  : array<string|int, mixed>
Stack used for storing array and retrieving register arrays.
$rootLine  : array<int, array<string, mixed>>
Use $request->getAttribute('frontend.page.information')->getRootLine() instead.
$sys_page  : PageRepository
Create own instance using GeneralUtility::makeInstance(PageRepository::class).
$cacheTimeOutDefault  : int
Is set to the time-to-live time of cached pages. Default is 60*60*24, which is 24 hours.
$contentType  : string
Content type HTTP header being sent in the request.
$context  : Context
The context for keeping the current state, mostly related to current page information, backend user / frontend user access, workspaceId
$languageService  : LanguageService
$pageCache  : FrontendInterface
$pageRenderer  : PageRenderer|null
$uniqueCounter  : int
Used to generate page-unique keys. Point is that uniqid() functions is very slow, so a unique key is made based on this, see function uniqueHash()
$uniqueString  : string

Methods

__construct()  : mixed
addCacheTags()  : mixed
Adds tags to this page's cache entry, you can then f.e. remove cache entries by tag
applyHttpHeadersToResponse()  : ResponseInterface
Add HTTP headers to the response object.
generatePage_postProcessing()  : void
Does processing of the content after the page content was generated.
generatePageTitle()  : string
Generate the page title, can be called multiple times, as PageTitleProvider might have been modified by an uncached plugin etc.
getPageCacheTags()  : array<string|int, mixed>
initializeLanguageService()  : void
This is only needed for sL() to be initialized properly.
initializePageRenderer()  : void
INTincScript()  : void
Processes the INTinclude-scripts
INTincScript_loadJSCode()  : void
Loads the JavaScript/CSS code for INTincScript, if there are non-cacheable content objects it prepares the placeholders, otherwise populates options directly.
isGeneratePage()  : bool
Returns TRUE if the page content should be generated.
isINTincScript()  : bool
Determines if there are any INTincScripts to include = "non-cacheable" parts
isStaticCacheble()  : bool
Reporting status whether we can send cache control headers for proxy caching or publishing to static files
logDeprecatedTyposcript()  : void
Logs access to deprecated TypoScript objects and properties.
newCObj()  : void
Creates an instance of ContentObjectRenderer in $this->cObj This instance is used to start the rendering of the TypoScript template structure
preparePageContentGeneration()  : void
Sets up TypoScript "config." options and set properties in $TSFE.
set_cache_timeout_default()  : void
Sets the default page cache timeout in seconds.
set_no_cache()  : void
Sets the cache-flag to 1. Could be called from user-included php-files in order to ensure that a page is not cached.
setContentType()  : void
sL()  : string
Split Label function for front-end applications.
uniqueHash()  : string
Returns a unique md5 hash.
get_cache_timeout()  : int
Get the cache timeout for the current page.
getAdditionalHeaders()  : array<string|int, mixed>
Send additional headers from config.additionalHeaders
getBackendUser()  : FrontendBackendUserAuthentication|null
getCacheHeaders()  : array<string|int, mixed>
Get cache headers good for client/reverse proxy caching.
getTimeTracker()  : TimeTracker
getWebsiteTitle()  : string
printTitle()  : string
Compiles the content for the page <title> tag.
processNonCacheableContentPartsAndSubstituteContentMarkers()  : void
Processes the INTinclude-scripts and substitute in content.
recursivelyReplaceIntPlaceholdersInContent()  : void
Replaces INT placeholders (COA_INT and USER_INT) in $this->content In case the replacement adds additional placeholders, it loops until no new placeholders are found any more.
setAbsRefPrefix()  : void
Converts relative paths in the HTML source to absolute paths for fileadmin/, typo3conf/ext/ and media/ folders.
setPageCacheContent()  : void
Sets cache content; Inserts the content string into the pages cache.
setSysLastChanged()  : void
Setting the SYS_LASTCHANGED value in the pagerecord: This value will thus be set to the highest tstamp of records rendered on the page.

Properties

$absRefPrefix

Absolute Reference prefix.

public string $absRefPrefix = ''
Internal

Used by content generation and link builders. Will be modeled differently in TYPO3 v14.

$additionalFooterData

Used to accumulate additional HTML-code for the footer-section of the template

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

$additionalHeaderData

Eg. insert JS-functions in this array ($additionalHeaderData) to include them once. Use associative keys.

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

Keys in use:

used to accumulate additional HTML-code for the header-section,

.... Insert either associative keys (like additionalHeaderData['myStyleSheet'], see reserved keys above) or num-keys (like additionalHeaderData[] = '...')
Internal

$cacheGenerated

public int $cacheGenerated = 0
Internal

Used by a middleware. Will be removed.

$cObj

Page content render object.

public ContentObjectRenderer $cObj
Internal

Still used is some cases.

Use instead: $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class, $this); $cObj->setRequest($request); $cObj->start($request->getAttribute('frontend.page.information')->getPageRecord(), 'pages');

$config

A central data array consisting of various keys, initialized and processed at various places in the class.

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

This array is cached along with the rendered page content and contains for instance a list of INT identifiers used to calculate 'dynamic' page parts when a page is retrieved from cache.

Remaining core @internal uses: 'INTincScript': (internal) List of INT instructions 'INTincScript_ext': (internal) Further state for INT instructions 'pageTitleCache': (internal)

Use $request->getAttribute('frontend.typoscript')->getConfigArray() instead.

$content

All page content is accumulated in this variable. See RequestHandler

public string $content = ''
Internal

$contentPid

Available as @internal $request->getAttribute('frontend.page.information')->getContentFromPid().

public int $contentPid = 0

$currentRecord

This is set to the [table]:[uid] of the latest record rendered. Note that class ContentObjectRenderer has an equal value, but that is pointing to the record delivered in the $data-array of the ContentObjectRenderer instance, if the cObjects CONTENT or RECORD created that instance

public string $currentRecord = ''
Internal

$debugInformationHeader

If debug mode is enabled, this contains the information if a page is fetched from cache, and sent as HTTP Response Header.

public string|null $debugInformationHeader = null
Internal

Used by a middleware. Will be removed.

$id

Use $request->getAttribute('frontend.page.information')->getId() instead.

public int $id

$newHash

This hash is unique to the page id, involved TS templates, TS condition verdicts, and some other parameters that influence page render result. Used to get/set page cache.

public string $newHash = ''
Internal

$page

Use $request->getAttribute('frontend.page.information')->getPageRecord() instead.

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

$pageContentWasLoadedFromCache

Set if cached content was fetched from the cache.

public bool $pageContentWasLoadedFromCache = false
Internal

Used by a middleware. Will be removed.

$recordRegister

Used by RecordContentObject and ContentContentObject to ensure the a records is NOT rendered twice through it!

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

$register

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

$registerStack

Stack used for storing array and retrieving register arrays.

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

See LOAD_REGISTER and RESTORE_REGISTER.

Internal

$rootLine

Use $request->getAttribute('frontend.page.information')->getRootLine() instead.

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

$sys_page

Create own instance using GeneralUtility::makeInstance(PageRepository::class).

public PageRepository $sys_page

$cacheTimeOutDefault

Is set to the time-to-live time of cached pages. Default is 60*60*24, which is 24 hours.

protected int $cacheTimeOutDefault = 0

$contentType

Content type HTTP header being sent in the request.

protected string $contentType = 'text/html; charset=utf-8'
Tags
todo

Ticket: #63642 Should be refactored to a request/response model later

$context

The context for keeping the current state, mostly related to current page information, backend user / frontend user access, workspaceId

protected Context $context

$uniqueCounter

Used to generate page-unique keys. Point is that uniqid() functions is very slow, so a unique key is made based on this, see function uniqueHash()

protected int $uniqueCounter = 0

$uniqueString

protected string $uniqueString = ''

Methods

__construct()

public __construct() : mixed
Internal

Extensions should usually not need to create own instances of TSFE

addCacheTags()

Adds tags to this page's cache entry, you can then f.e. remove cache entries by tag

public addCacheTags(array<string|int, mixed> $tags) : mixed
Deprecated

since TYPO3 v13, will be removed in TYPO3 v14. Use $request->getAttribute('frontend.cache.collector')->addCacheTags(new CacheTag($tag, $lifetime)) instead.

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

An array of tag

applyHttpHeadersToResponse()

Add HTTP headers to the response object.

public applyHttpHeadersToResponse(ServerRequestInterface $request, ResponseInterface $response) : ResponseInterface
Parameters
$request : ServerRequestInterface
$response : ResponseInterface
Internal
Return values
ResponseInterface

generatePage_postProcessing()

Does processing of the content after the page content was generated.

public generatePage_postProcessing(ServerRequestInterface $request) : void

This includes caching the page, indexing the page (if configured) and setting sysLastChanged

Parameters
$request : ServerRequestInterface
Internal

generatePageTitle()

Generate the page title, can be called multiple times, as PageTitleProvider might have been modified by an uncached plugin etc.

public generatePageTitle(ServerRequestInterface $request) : string
Parameters
$request : ServerRequestInterface
Internal
Return values
string

getPageCacheTags()

public getPageCacheTags() : array<string|int, mixed>
Deprecated

since TYPO3 v13, will be removed in TYPO3 v14. Use $request->getAttribute('frontend.cache.collector')->getCacheTags() instead.

Return values
array<string|int, mixed>

initializeLanguageService()

This is only needed for sL() to be initialized properly.

public initializeLanguageService(ServerRequestInterface $request) : void
Parameters
$request : ServerRequestInterface
Internal

initializePageRenderer()

public initializePageRenderer(ServerRequestInterface $request) : void
Parameters
$request : ServerRequestInterface
Internal

INTincScript()

Processes the INTinclude-scripts

public INTincScript(ServerRequestInterface $request) : void
Parameters
$request : ServerRequestInterface
Internal

INTincScript_loadJSCode()

Loads the JavaScript/CSS code for INTincScript, if there are non-cacheable content objects it prepares the placeholders, otherwise populates options directly.

public INTincScript_loadJSCode() : void
Internal

this method should be renamed as it does not only handle JS, but all additional header data

isGeneratePage()

Returns TRUE if the page content should be generated.

public isGeneratePage() : bool
Internal
Return values
bool

isINTincScript()

Determines if there are any INTincScripts to include = "non-cacheable" parts

public isINTincScript() : bool
Internal
Return values
bool

Returns TRUE if scripts are found

isStaticCacheble()

Reporting status whether we can send cache control headers for proxy caching or publishing to static files

public isStaticCacheble(ServerRequestInterface $request) : bool

Rules are: no_cache cannot be set: If it is, the page might contain dynamic content and should never be cached. There can be no USER_INT objects on the page ("isINTincScript()") because they implicitly indicate dynamic content There can be no logged-in user because user sessions are based on a cookie and thereby does not offer client caching a chance to know if the user is logged in. Actually, there will be a reverse problem here; If a page will somehow change when a user is logged in he may not see it correctly if the non-login version sent a cache-header! So do NOT use cache headers in page sections where user logins change the page content. (unless using such as realurl to apply a prefix in case of login sections)

Parameters
$request : ServerRequestInterface
Internal
Return values
bool

logDeprecatedTyposcript()

Logs access to deprecated TypoScript objects and properties.

public logDeprecatedTyposcript(string $typoScriptProperty[, string $explanation = '' ]) : void

Dumps message to the TypoScript message log (admin panel) and the TYPO3 deprecation log.

Parameters
$typoScriptProperty : string

Deprecated object or property

$explanation : string = ''

Message or additional information

Internal

newCObj()

Creates an instance of ContentObjectRenderer in $this->cObj This instance is used to start the rendering of the TypoScript template structure

public newCObj(ServerRequestInterface $request) : void
Parameters
$request : ServerRequestInterface
Internal

preparePageContentGeneration()

Sets up TypoScript "config." options and set properties in $TSFE.

public preparePageContentGeneration(ServerRequestInterface $request) : void
Parameters
$request : ServerRequestInterface
Internal

set_cache_timeout_default()

Sets the default page cache timeout in seconds.

public set_cache_timeout_default(int $seconds) : void

Unused.

Parameters
$seconds : int

set_no_cache()

Sets the cache-flag to 1. Could be called from user-included php-files in order to ensure that a page is not cached.

public set_no_cache([string $reason = '' ]) : void

Use :php:$request->getAttribute('frontend.cache.instruction')->disableCache() instead.

Parameters
$reason : string = ''

An optional reason to be written to the log.

setContentType()

public setContentType(string $contentType) : void
Parameters
$contentType : string
Internal

Must only be used by TYPO3 core

sL()

Split Label function for front-end applications.

public sL(string $input) : string

$languageService = GeneralUtility::makeInstance(LanguageServiceFactory::class) ->createFromSiteLanguage($request->getAttribute('language'))->sL() instead.

Parameters
$input : string

Key string. Accepts the "LLL:" prefix.

Return values
string

Label value, if any.

uniqueHash()

Returns a unique md5 hash.

public uniqueHash([string $str = '' ]) : string

There is no special magic in this, the only point is that you don't have to call md5(uniqid()) which is slow and by this you are sure to get a unique string each time in a little faster way.

Parameters
$str : string = ''

Some string to include in what is hashed. Not significant at all.

Internal
Return values
string

MD5 hash of ->uniqueString, input string and uniqueCounter

get_cache_timeout()

Get the cache timeout for the current page.

protected get_cache_timeout(ServerRequestInterface $request) : int
Parameters
$request : ServerRequestInterface
Return values
int

getAdditionalHeaders()

Send additional headers from config.additionalHeaders

protected getAdditionalHeaders(ServerRequestInterface $request) : array<string|int, mixed>
Parameters
$request : ServerRequestInterface
Return values
array<string|int, mixed>

getCacheHeaders()

Get cache headers good for client/reverse proxy caching.

protected getCacheHeaders(ServerRequestInterface $request) : array<string|int, mixed>
Parameters
$request : ServerRequestInterface
Return values
array<string|int, mixed>

getWebsiteTitle()

protected getWebsiteTitle(ServerRequestInterface $request) : string
Parameters
$request : ServerRequestInterface
Return values
string

printTitle()

Compiles the content for the page <title> tag.

protected printTitle(ServerRequestInterface $request, string $pageTitle[, bool $noPageTitle = false ][, bool $showPageTitleFirst = false ][, string $pageTitleSeparator = '' ][, bool $showWebsiteTitle = true ]) : string
Parameters
$request : ServerRequestInterface
$pageTitle : string

The input title string, typically the "title" field of a page's record.

$noPageTitle : bool = false

If set, the page title will not be printed

$showPageTitleFirst : bool = false

If set, website title and page title are swapped

$pageTitleSeparator : string = ''

an alternative to the ": " as the separator between site title and page title

$showWebsiteTitle : bool = true

If set, the website title will be printed

Tags
see
generatePageTitle()
Return values
string

The page title on the form "[website title]: [input-title]". Not htmlspecialchar()'ed.

processNonCacheableContentPartsAndSubstituteContentMarkers()

Processes the INTinclude-scripts and substitute in content.

protected processNonCacheableContentPartsAndSubstituteContentMarkers(array<string|int, mixed> $nonCacheableData, ServerRequestInterface $request) : void

Takes $this->content, and splits the content by and then puts the content back together.

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

$GLOBALS['TSFE']->config['INTincScript'] or part of it

$request : ServerRequestInterface
Tags
see
INTincScript()

recursivelyReplaceIntPlaceholdersInContent()

Replaces INT placeholders (COA_INT and USER_INT) in $this->content In case the replacement adds additional placeholders, it loops until no new placeholders are found any more.

protected recursivelyReplaceIntPlaceholdersInContent(ServerRequestInterface $request) : void
Parameters
$request : ServerRequestInterface

setAbsRefPrefix()

Converts relative paths in the HTML source to absolute paths for fileadmin/, typo3conf/ext/ and media/ folders.

protected setAbsRefPrefix() : void
Tags
see
RequestHandler
see
INTincScript()

setPageCacheContent()

Sets cache content; Inserts the content string into the pages cache.

protected setPageCacheContent(ServerRequestInterface $request, string $content, array<string|int, mixed> $INTincScript, array<string|int, mixed> $INTincScript_ext, array<string|int, mixed> $pageTitleCache) : void
Parameters
$request : ServerRequestInterface
$content : string

The content to store in the HTML field of the cache table

$INTincScript : array<string|int, mixed>
$INTincScript_ext : array<string|int, mixed>
$pageTitleCache : array<string|int, mixed>
Tags
see
PrepareTypoScriptFrontendRendering

setSysLastChanged()

Setting the SYS_LASTCHANGED value in the pagerecord: This value will thus be set to the highest tstamp of records rendered on the page.

protected setSysLastChanged(ServerRequestInterface $request) : void

This includes all records with no regard to hidden records, userprotection and so on.

The important part is that this actually updates a translated "pages" record (_LOCALIZED_UID) if the Frontend is called with a translation.

Parameters
$request : ServerRequestInterface
Tags
see
ContentObjectRenderer::lastChanged()
see
setRegisterValueForSysLastChanged()

        
On this page

Search results