IncludeTreeSetupConditionConstantSubstitutionVisitor implements IncludeTreeVisitorInterface

FinalYes

Handle constants within (TS setup) conditions: When a conditional include is like this: '["{$foo.bar}" == "4711"]', this visitor looks up 'foo.bar in given (flattened) constants and substitutes it with the constant value.

The 'include' object then contains the substituted condition token for 'getConditionToken()', while the original token without the substitution is parked in 'getOriginalConditionToken()'. The latter is done to have the original token available in the backend to show, it is irrelevant in frontend.

Tags
internal:

Internal tree structure.

Table of Contents

Interfaces

IncludeTreeVisitorInterface
A visitor that can be attached to IncludeTreeTraverser's.

Methods

setFlattenedConstants()  : void
Must be set when adding this visitor, to an empty array at least.
visit()  : void
Main visit method called for each node.
visitBeforeChildren()  : void
Do the magic, see tests for details.

Methods

setFlattenedConstants()

Must be set when adding this visitor, to an empty array at least.

public setFlattenedConstants(array<string, string> $flattenedConstants) : void

Will fatal otherwise, and that's fine, since if not setting this, this visitor is useless and shouldn't be added at all.

Parameters
$flattenedConstants : array<string, string>

visitBeforeChildren()

Do the magic, see tests for details.

public visitBeforeChildren(IncludeInterface $include, int $currentDepth) : void

Implementation within 'visitBeforeChilden()' since this allows running both this visitor first, and then TreeVisitorConditionMatcher directly afterwards in the same traverser cycle!

Parameters
$include : IncludeInterface
$currentDepth : int

        
On this page

Search results