TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Fluid\Core\Parser\TemplateParser Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\Core\Parser\TemplateParser:
Tx_Fluid_Core_Parser_TemplateParser

Public Member Functions

 __construct ()
 
 injectSettings (array $settings)
 
 setConfiguration (\TYPO3\CMS\Fluid\Core\Parser\Configuration $configuration=NULL)
 
 parse ($templateString)
 
 getNamespaces ()
 

Public Attributes

const CONTEXT_INSIDE_VIEWHELPER_ARGUMENTS = 1
 
const CONTEXT_OUTSIDE_VIEWHELPER_ARGUMENTS = 2
 

Static Public Attributes

static $SCAN_PATTERN_NAMESPACEDECLARATION = '/(?<!\\\\){namespace\\s*(?P<identifier>[a-zA-Z]+[a-zA-Z0-9]*)\\s*=\\s*(?P<phpNamespace>(?:[A-Za-z0-9\.]+|Tx)(?:LEGACY_NAMESPACE_SEPARATOR\\w+|FLUID_NAMESPACE_SEPARATOR\\w+)+)\\s*}/m'
 
static $SCAN_PATTERN_XMLNSDECLARATION = '/\sxmlns:(?P<identifier>.*?)="(?P<xmlNamespace>.*?)"/m'
 
static $SPLIT_PATTERN_TEMPLATE_DYNAMICTAGS
 
static $SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG
 
static $SCAN_PATTERN_TEMPLATE_CLOSINGVIEWHELPERTAG = '/^<\\/(?P<NamespaceIdentifier>NAMESPACE):(?P<MethodIdentifier>[a-zA-Z0-9\\.]+)\\s*>$/'
 
static $SPLIT_PATTERN_TAGARGUMENTS
 
static $SCAN_PATTERN_CDATA = '/^<!\\[CDATA\\[(.*?)\\]\\]>$/s'
 
static $SPLIT_PATTERN_SHORTHANDSYNTAX
 
static $SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS
 
static $SPLIT_PATTERN_SHORTHANDSYNTAX_VIEWHELPER
 
static $SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS
 
static $SPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS
 
static $SCAN_PATTERN_DEFAULT_XML_NAMESPACE = '/^http\:\/\/typo3\.org\/ns\/(?P<PhpNamespace>.+)$/s'
 

Protected Member Functions

 reset ()
 
 extractNamespaceDefinitions ($templateString)
 
 splitTemplateAtDynamicTags ($templateString)
 
 buildObjectTree ($splitTemplate, $context)
 
 openingViewHelperTagHandler (\TYPO3\CMS\Fluid\Core\Parser\ParsingState $state, $namespaceIdentifier, $methodIdentifier, $arguments, $selfclosing)
 
 initializeViewHelperAndAddItToStack (\TYPO3\CMS\Fluid\Core\Parser\ParsingState $state, $namespaceIdentifier, $methodIdentifier, $argumentsObjectTree)
 
 abortIfUnregisteredArgumentsExist ($expectedArguments, $actualArguments)
 
 abortIfRequiredArgumentsAreMissing ($expectedArguments, $actualArguments)
 
 rewriteBooleanNodesInArgumentsObjectTree ($argumentDefinitions, &$argumentsObjectTree)
 
 resolveViewHelperName ($namespaceIdentifier, $methodIdentifier)
 
 closingViewHelperTagHandler (\TYPO3\CMS\Fluid\Core\Parser\ParsingState $state, $namespaceIdentifier, $methodIdentifier)
 
 objectAccessorHandler (\TYPO3\CMS\Fluid\Core\Parser\ParsingState $state, $objectAccessorString, $delimiter, $viewHelperString, $additionalViewHelpersString)
 
 callInterceptor (\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface &$node, $interceptionPoint, \TYPO3\CMS\Fluid\Core\Parser\ParsingState $state)
 
 postProcessArgumentsForObjectAccessor (array $arguments)
 
 parseArguments ($argumentsString)
 
 buildArgumentObjectTree ($argumentString)
 
 unquoteString ($quotedValue)
 
 prepareTemplateRegularExpression ($regularExpression)
 
 textAndShorthandSyntaxHandler (\TYPO3\CMS\Fluid\Core\Parser\ParsingState $state, $text, $context)
 
 arrayHandler (\TYPO3\CMS\Fluid\Core\Parser\ParsingState $state, $arrayText)
 
 recursiveArrayHandler ($arrayText)
 
 textHandler (\TYPO3\CMS\Fluid\Core\Parser\ParsingState $state, $text)
 

Protected Attributes

 $namespaces
 
 $objectManager
 
 $configuration
 
 $settings
 
 $viewHelperNameToImplementationClassNameRuntimeCache = array()
 

Detailed Description

Template parser building up an object syntax tree

Definition at line 17 of file TemplateParser.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::__construct ( )

Constructor. Preprocesses the $SCAN_PATTERN_NAMESPACEDECLARATION by inserting the correct namespace separator.

Definition at line 279 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Fluid\LEGACY_NAMESPACE_SEPARATOR, and TYPO3\CMS\Fluid\Fluid\NAMESPACE_SEPARATOR.

Member Function Documentation

◆ abortIfRequiredArgumentsAreMissing()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::abortIfRequiredArgumentsAreMissing (   $expectedArguments,
  $actualArguments 
)
protected

Throw an exception if required arguments are missing

Parameters
array$expectedArgumentsArray of of all expected arguments
array$actualArgumentsActual arguments
Exceptions

Definition at line 547 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\initializeViewHelperAndAddItToStack().

◆ abortIfUnregisteredArgumentsExist()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::abortIfUnregisteredArgumentsExist (   $expectedArguments,
  $actualArguments 
)
protected

Throw an exception if there are arguments which were not registered before.

Parameters
array$expectedArgumentsArray of of all expected arguments
array$actualArgumentsActual arguments
Exceptions

Definition at line 527 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\initializeViewHelperAndAddItToStack().

◆ arrayHandler()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::arrayHandler ( \TYPO3\CMS\Fluid\Core\Parser\ParsingState  $state,
  $arrayText 
)
protected

Handler for array syntax. This creates the array object recursively and adds it to the current node.

Parameters
\TYPO3\CMS\Fluid\Core\Parser\ParsingState$stateThe current parsing state
string$arrayTextThe array as string.
Returns
void

Definition at line 832 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\textAndShorthandSyntaxHandler().

◆ buildArgumentObjectTree()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::buildArgumentObjectTree (   $argumentString)
protected

Build up an argument object tree for the string in $argumentString. This builds up the tree for a single argument value.

This method also does some performance optimizations, so in case no { or < is found, then we just return a TextNode.

Parameters
string$argumentString
Returns
SyntaxTree the corresponding argument object tree.

Definition at line 754 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\buildObjectTree(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\splitTemplateAtDynamicTags().

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\parseArguments(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\recursiveArrayHandler().

◆ buildObjectTree()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::buildObjectTree (   $splitTemplate,
  $context 
)
protected

Build object tree from the split template

Parameters
array$splitTemplateThe split template, so that every tag with a namespace declaration is already a separate array element.
integer$contextone of the CONTEXT_* constants, defining whether we are inside or outside of ViewHelper arguments currently.
Returns
Exceptions

Definition at line 427 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\closingViewHelperTagHandler(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\openingViewHelperTagHandler(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\prepareTemplateRegularExpression(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\textAndShorthandSyntaxHandler(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\textHandler().

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\buildArgumentObjectTree(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\parse().

◆ callInterceptor()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::callInterceptor ( \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface $node,
  $interceptionPoint,
\TYPO3\CMS\Fluid\Core\Parser\ParsingState  $state 
)
protected

Call all interceptors registered for a given interception point.

Parameters
\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface$nodeThe syntax tree node which can be modified by the interceptors.
integer$interceptionPointthe interception point. One of the ::INTERCEPT_* constants.
\TYPO3\CMS\Fluid\Core\Parser\ParsingState$statethe parsing state
Returns
void

Definition at line 687 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\closingViewHelperTagHandler(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\initializeViewHelperAndAddItToStack(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\objectAccessorHandler(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\openingViewHelperTagHandler(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\textHandler().

◆ closingViewHelperTagHandler()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::closingViewHelperTagHandler ( \TYPO3\CMS\Fluid\Core\Parser\ParsingState  $state,
  $namespaceIdentifier,
  $methodIdentifier 
)
protected

Handles a closing view helper tag

Parameters
\TYPO3\CMS\Fluid\Core\Parser\ParsingState$stateThe current parsing state
string$namespaceIdentifierNamespace identifier for the closing tag.
string$methodIdentifierMethod identifier.
Returns
void
Exceptions

Definition at line 608 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\callInterceptor(), TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface\INTERCEPT_CLOSING_VIEWHELPER, and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\resolveViewHelperName().

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\buildObjectTree().

◆ extractNamespaceDefinitions()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::extractNamespaceDefinitions (   $templateString)
protected

Extracts namespace definitions out of the given template string and sets $this->namespaces.

Parameters
string$templateStringTemplate string to extract the namespaces from
Returns
string The updated template string without namespace declarations inside
Exceptions

Definition at line 371 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\parse().

◆ getNamespaces()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::getNamespaces ( )

Gets the namespace definitions found.

Returns
array Namespace identifiers and their component name prefix

Definition at line 348 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\$namespaces.

◆ initializeViewHelperAndAddItToStack()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::initializeViewHelperAndAddItToStack ( \TYPO3\CMS\Fluid\Core\Parser\ParsingState  $state,
  $namespaceIdentifier,
  $methodIdentifier,
  $argumentsObjectTree 
)
protected

Initialize the given ViewHelper and adds it to the current node and to the stack.

Parameters
\TYPO3\CMS\Fluid\Core\Parser\ParsingState$stateCurrent parsing state
string$namespaceIdentifierNamespace identifier - being looked up in $this->namespaces
string$methodIdentifierMethod identifier
array$argumentsObjectTreeArguments object tree
Returns
void
Exceptions

Definition at line 486 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\abortIfRequiredArgumentsAreMissing(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\abortIfUnregisteredArgumentsExist(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\callInterceptor(), TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface\INTERCEPT_OPENING_VIEWHELPER, TYPO3\CMS\Fluid\Core\Parser\TemplateParser\resolveViewHelperName(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\rewriteBooleanNodesInArgumentsObjectTree().

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\objectAccessorHandler(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\openingViewHelperTagHandler().

◆ injectSettings()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::injectSettings ( array  $settings)

Injects Fluid settings

Parameters
array$settings

Definition at line 298 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\$settings.

◆ objectAccessorHandler()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::objectAccessorHandler ( \TYPO3\CMS\Fluid\Core\Parser\ParsingState  $state,
  $objectAccessorString,
  $delimiter,
  $viewHelperString,
  $additionalViewHelpersString 
)
protected

Handles the appearance of an object accessor (like {posts.author.email}). Creates a new instance of .

Handles ViewHelpers as well which are in the shorthand syntax.

Parameters
\TYPO3\CMS\Fluid\Core\Parser\ParsingState$stateThe current parsing state
string$objectAccessorStringString which identifies which objects to fetch
string$delimiter
string$viewHelperString
string$additionalViewHelpersString
Returns
void

Definition at line 635 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\callInterceptor(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\initializeViewHelperAndAddItToStack(), TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface\INTERCEPT_CLOSING_VIEWHELPER, TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface\INTERCEPT_OBJECTACCESSOR, TYPO3\CMS\Fluid\Core\Parser\TemplateParser\postProcessArgumentsForObjectAccessor(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\recursiveArrayHandler().

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\textAndShorthandSyntaxHandler().

◆ openingViewHelperTagHandler()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::openingViewHelperTagHandler ( \TYPO3\CMS\Fluid\Core\Parser\ParsingState  $state,
  $namespaceIdentifier,
  $methodIdentifier,
  $arguments,
  $selfclosing 
)
protected

Handles an opening or self-closing view helper tag.

Parameters
\TYPO3\CMS\Fluid\Core\Parser\ParsingState$stateCurrent parsing state
string$namespaceIdentifierNamespace identifier - being looked up in $this->namespaces
string$methodIdentifierMethod identifier
string$argumentsArguments string, not yet parsed
boolean$selfclosingtrue, if the tag is a self-closing tag.
Returns
void

Definition at line 465 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\callInterceptor(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\initializeViewHelperAndAddItToStack(), TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface\INTERCEPT_CLOSING_VIEWHELPER, and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\parseArguments().

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\buildObjectTree().

◆ parse()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::parse (   $templateString)

Parses a given template string and returns a parsed template object.

The resulting ParsedTemplate can then be rendered by calling evaluate() on it.

Normally, you should use a subclass of AbstractTemplateView instead of calling the TemplateParser directly.

Parameters
string$templateStringThe template to parse as a string
Returns
Parsed template
Exceptions

Definition at line 324 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\buildObjectTree(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\extractNamespaceDefinitions(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\reset(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\splitTemplateAtDynamicTags().

◆ parseArguments()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::parseArguments (   $argumentsString)
protected

Parse arguments of a given tag, and build up the Arguments Object Tree for each argument. Returns an associative array, where the key is the name of the argument, and the value is a single Argument Object Tree.

Parameters
string$argumentsStringAll arguments as string
Returns
array An associative array of objects, where the key is the argument name.

Definition at line 728 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\$configuration, TYPO3\CMS\Fluid\Core\Parser\TemplateParser\buildArgumentObjectTree(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\unquoteString().

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\openingViewHelperTagHandler().

◆ postProcessArgumentsForObjectAccessor()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::postProcessArgumentsForObjectAccessor ( array  $arguments)
protected

Post process the arguments for the ViewHelpers in the object accessor syntax. We need to convert an array into an array of (only) nodes

Parameters
array$argumentsThe arguments to be processed
Returns
array the processed array
Todo:
This method should become superflous once the rest has been refactored, so that this code is not needed.

Definition at line 710 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\objectAccessorHandler().

◆ prepareTemplateRegularExpression()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::prepareTemplateRegularExpression (   $regularExpression)
protected

Takes a regular expression template and replaces "NAMESPACE" with the currently registered namespace identifiers. Returns a regular expression which is ready to use.

Parameters
string$regularExpressionRegular expression template
Returns
string Regular expression ready to be used

Definition at line 794 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\buildObjectTree(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\splitTemplateAtDynamicTags(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\textAndShorthandSyntaxHandler().

◆ recursiveArrayHandler()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::recursiveArrayHandler (   $arrayText)
protected

Recursive function which takes the string representation of an array and builds an object tree from it.

Deals with the following value types:

  • Numbers (Integers and Floats)
  • Strings
  • Variables
  • sub-arrays
Parameters
string$arrayTextArray text
Returns
SyntaxTree the array node built up
Exceptions

Definition at line 852 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\buildArgumentObjectTree(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\unquoteString().

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\objectAccessorHandler().

◆ reset()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::reset ( )
protected

Resets the parser to its default values.

Returns
void

Definition at line 357 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\parse().

◆ resolveViewHelperName()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::resolveViewHelperName (   $namespaceIdentifier,
  $methodIdentifier 
)
protected

Resolve a viewhelper name.

Parameters
string$namespaceIdentifierNamespace identifier for the view helper.
string$methodIdentifierMethod identifier, might be hierarchical like "link.url"
Returns
string The fully qualified class name of the viewhelper

Definition at line 578 of file TemplateParser.php.

References TYPO3\CMS\Core\Core\ClassLoader\getClassNameForAlias(), TYPO3\CMS\Fluid\Fluid\LEGACY_NAMESPACE_SEPARATOR, and TYPO3\CMS\Fluid\Fluid\NAMESPACE_SEPARATOR.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\closingViewHelperTagHandler(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\initializeViewHelperAndAddItToStack().

◆ rewriteBooleanNodesInArgumentsObjectTree()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::rewriteBooleanNodesInArgumentsObjectTree (   $argumentDefinitions,
$argumentsObjectTree 
)
protected

Wraps the argument tree, if a node is boolean, into a Boolean syntax tree node

Parameters
array$argumentDefinitionsthe argument definitions, key is the argument name, value is the ArgumentDefinition object
array$argumentsObjectTreethe arguments syntax tree, key is the argument name, value is an AbstractNode
Returns
void

Definition at line 563 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\initializeViewHelperAndAddItToStack().

◆ setConfiguration()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::setConfiguration ( \TYPO3\CMS\Fluid\Core\Parser\Configuration  $configuration = NULL)

Set the configuration for the parser.

Parameters
\TYPO3\CMS\Fluid\Core\Parser\Configuration$configuration
Returns
void

Definition at line 308 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\$configuration.

◆ splitTemplateAtDynamicTags()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::splitTemplateAtDynamicTags (   $templateString)
protected

Splits the template string on all dynamic tags found.

Parameters
string$templateStringTemplate string to split.
Returns
array Splitted template

Definition at line 414 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\prepareTemplateRegularExpression().

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\buildArgumentObjectTree(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\parse().

◆ textAndShorthandSyntaxHandler()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::textAndShorthandSyntaxHandler ( \TYPO3\CMS\Fluid\Core\Parser\ParsingState  $state,
  $text,
  $context 
)
protected

Handler for everything which is not a ViewHelperNode.

This includes Text, array syntax, and object accessor syntax.

Parameters
\TYPO3\CMS\Fluid\Core\Parser\ParsingState$stateCurrent parsing state
string$textText to process
integer$contextone of the CONTEXT_* constants, defining whether we are inside or outside of ViewHelper arguments currently.
Returns
void

Definition at line 808 of file TemplateParser.php.

References TYPO3\CMS\Fluid\Core\Parser\TemplateParser\arrayHandler(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\objectAccessorHandler(), TYPO3\CMS\Fluid\Core\Parser\TemplateParser\prepareTemplateRegularExpression(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\textHandler().

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\buildObjectTree().

◆ textHandler()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::textHandler ( \TYPO3\CMS\Fluid\Core\Parser\ParsingState  $state,
  $text 
)
protected

◆ unquoteString()

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::unquoteString (   $quotedValue)
protected

Removes escapings from a given argument string and trims the outermost quotes.

This method is meant as a helper for regular expression results.

Parameters
string$quotedValueValue to unquote
Returns
string Unquoted value

Definition at line 772 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\parseArguments(), and TYPO3\CMS\Fluid\Core\Parser\TemplateParser\recursiveArrayHandler().

Member Data Documentation

◆ $configuration

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$configuration
protected

◆ $namespaces

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$namespaces
protected
Initial value:
= array(
'f' => 'TYPO3\\CMS\\Fluid\\ViewHelpers'
)

Definition at line 250 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Core\Parser\TemplateParser\getNamespaces().

◆ $objectManager

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$objectManager
protected

Definition at line 258 of file TemplateParser.php.

◆ $SCAN_PATTERN_CDATA

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SCAN_PATTERN_CDATA = '/^<!\\[CDATA\\[(.*?)\\]\\]>$/s'
static

This pattern detects CDATA sections and outputs the text between opening and closing CDATA.

Definition at line 108 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Tests\Unit\Core\Parser\TemplateParserPatternTest\testSCAN_PATTERN_CDATA().

◆ $SCAN_PATTERN_DEFAULT_XML_NAMESPACE

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SCAN_PATTERN_DEFAULT_XML_NAMESPACE = '/^http\:\/\/typo3\.org\/ns\/(?P<PhpNamespace>.+)$/s'
static

This pattern detects the default xml namespace

Definition at line 244 of file TemplateParser.php.

◆ $SCAN_PATTERN_NAMESPACEDECLARATION

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SCAN_PATTERN_NAMESPACEDECLARATION = '/(?<!\\\\){namespace\\s*(?P<identifier>[a-zA-Z]+[a-zA-Z0-9]*)\\s*=\\s*(?P<phpNamespace>(?:[A-Za-z0-9\.]+|Tx)(?:LEGACY_NAMESPACE_SEPARATOR\\w+|FLUID_NAMESPACE_SEPARATOR\\w+)+)\\s*}/m'
static

Definition at line 19 of file TemplateParser.php.

◆ $SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS
static
Initial value:
= '/^
(?P<Recursion> # Start the recursive part of the regular expression - describing the array syntax
{ # Each array needs to start with {
(?P<Array> # Start submatch
(?:
\\s*[a-zA-Z0-9\\-_]+ # The keys of the array
\\s*:\\s* # Key|Value delimiter :
(?: # Possible value options:
"(?:\\\\"|[^"])*" # Double qouoted string
|\'(?:\\\\\'|[^\'])*\' # Single quoted string
|[a-zA-Z0-9\\-_.]+ # variable identifiers
|(?P>Recursion) # Another sub-array
) # END possible value options
\\s*,? # There might be a , to separate different parts of the array
)* # The above cycle is repeated for all array elements
) # End array submatch
} # Each array ends with }
)$/x'

Pattern which detects the array/object syntax like in JavaScript, so it detects strings like: {object: value, object2: {nested: array}, object3: "Some string"}

THIS IS ALMOST THE SAME AS IN SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS

Definition at line 201 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Tests\Unit\Core\Parser\TemplateParserPatternTest\testSCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS().

◆ $SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS
static

Pattern which detects the object accessor syntax: {object.some.value}, additionally it detects ViewHelpers like {f:for(param1:bla)} and chaining like {object.some.value->f:bla.blubb()->f:bla.blubb2()}

THIS IS ALMOST THE SAME AS IN $SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS

Definition at line 135 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Tests\Unit\Core\Parser\TemplateParserPatternTest\testSCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS().

◆ $SCAN_PATTERN_TEMPLATE_CLOSINGVIEWHELPERTAG

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SCAN_PATTERN_TEMPLATE_CLOSINGVIEWHELPERTAG = '/^<\\/(?P<NamespaceIdentifier>NAMESPACE):(?P<MethodIdentifier>[a-zA-Z0-9\\.]+)\\s*>$/'
static

This regular expression scans if the input string is a closing ViewHelper tag.

Definition at line 83 of file TemplateParser.php.

◆ $SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG
static
Initial value:
= '/
^< # A Tag begins with <
(?P<NamespaceIdentifier>NAMESPACE): # Then comes the Namespace prefix followed by a :
(?P<MethodIdentifier> # Now comes the Name of the ViewHelper
[a-zA-Z0-9\\.]+
)
(?P<Attributes> # Begin Tag Attributes
(?: # A tag might have multiple attributes
\\s*
[a-zA-Z0-9:-]+ # The attribute name
= # =
(?> # either... # If we have found an argument, we will not back-track (That does the Atomic Bracket)
"(?:\\\\"|[^"])*" # a double-quoted string
|\'(?:\\\\\'|[^\'])*\' # or a single quoted string
) #
\\s*
)* # A tag might have multiple attributes
) # End Tag Attributes
\\s*
(?P<Selfclosing>\\/?) # A tag might be selfclosing
>$/x'

This regular expression scans if the input string is a ViewHelper tag

Definition at line 57 of file TemplateParser.php.

◆ $SCAN_PATTERN_XMLNSDECLARATION

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SCAN_PATTERN_XMLNSDECLARATION = '/\sxmlns:(?P<identifier>.*?)="(?P<xmlNamespace>.*?)"/m'
static

Definition at line 20 of file TemplateParser.php.

◆ $settings

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$settings
protected

◆ $SPLIT_PATTERN_SHORTHANDSYNTAX

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SPLIT_PATTERN_SHORTHANDSYNTAX
static
Initial value:
= '/
(
{ # Start of shorthand syntax
(?: # Shorthand syntax is either composed of...
[a-zA-Z0-9\\->_:,.()] # Various characters
|"(?:\\\\"|[^"])*" # Double-quoted strings
|\'(?:\\\\\'|[^\'])*\' # Single-quoted strings
|(?R) # Other shorthand syntaxes inside, albeit not in a quoted string
|\\s+ # Spaces
)+
} # End of shorthand syntax
)/x'

Pattern which splits the shorthand syntax into different tokens. The "shorthand syntax" is everything like {...}

Definition at line 114 of file TemplateParser.php.

◆ $SPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS
static
Initial value:
= '/
(?P<ArrayPart> # Start submatch
(?P<Key>[a-zA-Z0-9\\-_]+) # The keys of the array
\\s*:\\s* # Key|Value delimiter :
(?: # Possible value options:
(?P<QuotedString> # Quoted string
(?:"(?:\\\\"|[^"])*")
|(?:\'(?:\\\\\'|[^\'])*\')
)
|(?P<VariableIdentifier>[a-zA-Z][a-zA-Z0-9\\-_.]*) # variable identifiers have to start with a letter
|(?P<Number>[0-9.]+) # Number
|{\\s*(?P<Subarray>(?:(?P>ArrayPart)\\s*,?\\s*)+)\\s*} # Another sub-array
) # END possible value options
) # End array part submatch
/x'

This pattern splits an array into its parts. It is quite similar to the pattern above.

Definition at line 224 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Tests\Unit\Core\Parser\TemplateParserPatternTest\testSPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS().

◆ $SPLIT_PATTERN_SHORTHANDSYNTAX_VIEWHELPER

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SPLIT_PATTERN_SHORTHANDSYNTAX_VIEWHELPER
static
Initial value:
= '/
(?P<NamespaceIdentifier>[a-zA-Z0-9]+) # Namespace prefix of ViewHelper (as in $SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG)
:
(?P<MethodIdentifier>[a-zA-Z0-9\\.]+)
\\( # Opening parameter brackets of ViewHelper
(?P<ViewHelperArguments> # Start submatch for ViewHelper arguments. This is taken from $SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS
(?:
\\s*[a-zA-Z0-9\\-_]+ # The keys of the array
\\s*:\\s* # Key|Value delimiter :
(?: # Possible value options:
"(?:\\\\"|[^"])*" # Double qouoted string
|\'(?:\\\\\'|[^\'])*\' # Single quoted string
|[a-zA-Z0-9\\-_.]+ # variable identifiers
|{(?P>ViewHelperArguments)} # Another sub-array
) # END possible value options
\\s*,? # There might be a , to separate different parts of the array
)* # The above cycle is repeated for all array elements
) # End ViewHelper Arguments submatch
\\) # Closing parameter brackets of ViewHelper
/x'

THIS IS ALMOST THE SAME AS $SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS

Definition at line 172 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Tests\Unit\Core\Parser\TemplateParserPatternTest\testSPLIT_PATTERN_SHORTHANDSYNTAX_VIEWHELPER().

◆ $SPLIT_PATTERN_TAGARGUMENTS

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SPLIT_PATTERN_TAGARGUMENTS
static
Initial value:
= '/
(?: #
\\s* #
(?P<Argument> # The attribute name
[a-zA-Z0-9:-]+ #
) #
= # =
(?> # If we have found an argument, we will not back-track (That does the Atomic Bracket)
(?P<ValueQuoted> # either...
(?:"(?:\\\\"|[^"])*") # a double-quoted string
|(?:\'(?:\\\\\'|[^\'])*\') # or a single quoted string
)
)\\s*
)
/xs'

This regular expression splits the tag arguments into its parts

Definition at line 88 of file TemplateParser.php.

Referenced by TYPO3\CMS\Fluid\Tests\Unit\Core\Parser\TemplateParserPatternTest\testSPLIT_PATTERN_TAGARGUMENTS().

◆ $SPLIT_PATTERN_TEMPLATE_DYNAMICTAGS

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SPLIT_PATTERN_TEMPLATE_DYNAMICTAGS
static
Initial value:
= '/
(
(?: <\\/? # Start dynamic tags
(?:(?:NAMESPACE):[a-zA-Z0-9\\.]+) # A tag consists of the namespace prefix and word characters
(?: # Begin tag arguments
\\s*[a-zA-Z0-9:-]+ # Argument Keys
= # =
(?> # either... If we have found an argument, we will not back-track (That does the Atomic Bracket)
"(?:\\\\"|[^"])*" # a double-quoted string
|\'(?:\\\\\'|[^\'])*\' # or a single quoted string
)\\s* #
)* # Tag arguments can be replaced many times.
\\s*
\\/?> # Closing tag
)
|(?: # Start match CDATA section
<!\\[CDATA\\[.*?\\]\\]>
)
)/xs'

This regular expression splits the input string at all dynamic tags, AND on all <![CDATA[...]]> sections.

Definition at line 34 of file TemplateParser.php.

◆ $viewHelperNameToImplementationClassNameRuntimeCache

TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$viewHelperNameToImplementationClassNameRuntimeCache = array()
protected

Definition at line 273 of file TemplateParser.php.

◆ CONTEXT_INSIDE_VIEWHELPER_ARGUMENTS

const TYPO3\CMS\Fluid\Core\Parser\TemplateParser::CONTEXT_INSIDE_VIEWHELPER_ARGUMENTS = 1

The following two constants are used for tracking whether we are currently parsing ViewHelper arguments or not. This is used to parse arrays only as ViewHelper argument.

Definition at line 27 of file TemplateParser.php.

◆ CONTEXT_OUTSIDE_VIEWHELPER_ARGUMENTS

const TYPO3\CMS\Fluid\Core\Parser\TemplateParser::CONTEXT_OUTSIDE_VIEWHELPER_ARGUMENTS = 2

Definition at line 28 of file TemplateParser.php.