‪TYPO3CMS  ‪main
TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder Class Reference

Public Member Functions

 __construct (private readonly FileNameValidator $fileNameValidator,)
 
 buildTree (IncludeInterface $node, string $type, TokenizerInterface $tokenizer, bool $enableMagicIncludes=true)
 

Private Member Functions

 buildTreeInternal (IncludeInterface $node)
 
 processAtImport (string $fileSuffix, IncludeInterface $node, Token $atImportValueToken, LineInterface $atImportLine, bool $tryRelative=false)
 
 addSingleAtImportFile (IncludeInterface $parentNode, string $absoluteFileName, string $path, string $name, LineInterface $atImportLine)
 
 processIncludeTyposcript (IncludeInterface $node, Token $includeTyposcriptValueToken, LineInterface $importKeywordOldLine)
 
 processConditionalIncludeTyposcript (IncludeInterface $parentNode, ?string $condition, string $fileName)
 
 importIncludeTyposcriptDirectoryRecursive (IncludeInterface $nodeToAddTo, LineInterface $importKeywordOldLine, string $dirName, string $absoluteDirName, array $extensions)
 
 addSingleIncludeTyposcriptFile (IncludeInterface $parentNode, string $absoluteFileName, string $path, LineInterface $importKeywordOldLine)
 
 addStaticMagicFromGlobals (IncludeInterface $parentNode, string $path)
 

Private Attributes

string $type
 
TokenizerInterface $tokenizer
 
bool $enableMagicIncludes = false
 
array $atImportTypeToSuffixMap
 

Detailed Description

Helper class of TreeBuilder classes: This class gets a node with a LineStream - a node created from a sys_template 'constants' or 'setup' field, or created from a file import or a string. It then looks for conditions and imports in the attached LineStream and splits the node into child nodes if needed.

So while SysTemplateTreeBuilder is all about creating includes from sys_template records in correct order, this class takes care of conditions and @import within single source streams.

This class has no cache-implementation itself: The higher level class caches include trees of token streams.

: Internal tree structure.

Definition at line 57 of file TreeFromLineStreamBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder::__construct ( private readonly FileNameValidator  $fileNameValidator)

Definition at line 78 of file TreeFromLineStreamBuilder.php.

Member Function Documentation

◆ addSingleAtImportFile()

TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder::addSingleAtImportFile ( IncludeInterface  $parentNode,
string  $absoluteFileName,
string  $path,
string  $name,
LineInterface  $atImportLine 
)
private

Get content of a single @import file and add to current node as child.

Warning: Recursively calls buildTree() to process includes of included content.

Definition at line 357 of file TreeFromLineStreamBuilder.php.

References TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface\addChild(), and TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder\buildTreeInternal().

Referenced by TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder\processAtImport().

◆ addSingleIncludeTyposcriptFile()

TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder::addSingleIncludeTyposcriptFile ( IncludeInterface  $parentNode,
string  $absoluteFileName,
string  $path,
LineInterface  $importKeywordOldLine 
)
private

◆ addStaticMagicFromGlobals()

◆ buildTree()

◆ buildTreeInternal()

TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder::buildTreeInternal ( IncludeInterface  $node)
private

This method is a bit tricky and not too easy to follow: It loops over a given source stream of lines exactly once, but creates a two-level include node structure from it:

For instance, when a condition is encountered, it creates a node for the condition, and the "body" lines of the condition are child nodes of the condition node. The $previousNode <-> $node juggling handles this: When the condition body ends (new condition, or [end] or similar), the next include needs to be attached to the former parent node again.

Essentially, a single source stream is split into multiple child nodes when there are conditions or imports. A node that is "split" into child nodes gets the "split" toggle set, indicating that the entire source stream is represented by its child nodes.

A condition body may have more than one child: When there are multiple file includes, each one creates an own node, which may have children again. This also means the method is called recursive, since the source stream of an included file may need to be split into segments again, so it calls this method again with itself as entry node.

Definition at line 116 of file TreeFromLineStreamBuilder.php.

References TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder\$type, TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface\addChild(), TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface\getLineStream(), TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface\getName(), TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface\getPath(), TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface\isSplit(), TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder\processAtImport(), TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder\processIncludeTyposcript(), and TYPO3\CMS\Core\TypoScript\IncludeTree\IncludeNode\IncludeInterface\setSplit().

Referenced by TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder\addSingleAtImportFile(), TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder\addSingleIncludeTyposcriptFile(), TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder\addStaticMagicFromGlobals(), and TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder\buildTree().

◆ importIncludeTyposcriptDirectoryRecursive()

TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder::importIncludeTyposcriptDirectoryRecursive ( IncludeInterface  $nodeToAddTo,
LineInterface  $importKeywordOldLine,
string  $dirName,
string  $absoluteDirName,
array  $extensions 
)
private

◆ processAtImport()

TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder::processAtImport ( string  $fileSuffix,
IncludeInterface  $node,
Token  $atImportValueToken,
LineInterface  $atImportLine,
bool  $tryRelative = false 
)
private

◆ processConditionalIncludeTyposcript()

TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder::processConditionalIncludeTyposcript ( IncludeInterface  $parentNode,
?string  $condition,
string  $fileName 
)
private

When 'INCLUDE_TYPOSCRIPT' has a 'condition="..."' attribute, we create an additional ConditionIncludeTyposcriptInclude node the included file is added as child to. The method either returns current parent node if there is no condition, or the new conditional sub node, if there is one.

Definition at line 458 of file TreeFromLineStreamBuilder.php.

Referenced by TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder\processIncludeTyposcript().

◆ processIncludeTyposcript()

Member Data Documentation

◆ $atImportTypeToSuffixMap

array TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder::$atImportTypeToSuffixMap
private
Initial value:
= [
'constants' => ['typoscript'],
'setup' => ['typoscript'],
'other' => ['typoscript'],
'tsconfig' => ['typoscript', 'tsconfig'],
]

Definition at line 71 of file TreeFromLineStreamBuilder.php.

◆ $enableMagicIncludes

bool TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder::$enableMagicIncludes = false
private

◆ $tokenizer

TokenizerInterface TYPO3\CMS\Core\TypoScript\IncludeTree\TreeFromLineStreamBuilder::$tokenizer
private

◆ $type