TYPO3  7.6
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
TemplateParser Class Reference

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 $SCAN_PATTERN_NAMESPACE_FLUID_HTML_TAG = '/<html\\s++[^>]*data-namespace-typo3-fluid="true"[^>]*>/m'
 
static $SCAN_PATTERN_REMOVE_VIEWHELPERS_XMLNSDECLARATIONS = '/(?:\\s*+xmlns:(?:%1$s)="[^"]*"\\s*+)++/m'
 
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)
 
 removeXmlnsViewHelperNamespaceDeclarations ($templateString, array $foundIdentifiers)
 
 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 ( )

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

Definition at line 299 of file TemplateParser.php.

References Fluid\LEGACY_NAMESPACE_SEPARATOR, and Fluid\NAMESPACE_SEPARATOR.

Member Function Documentation

abortIfRequiredArgumentsAreMissing (   $expectedArguments,
  $actualArguments 
)
protected

Throw an exception if required arguments are missing

Parameters
array$expectedArgumentsArray of of all expected arguments
array$actualArgumentsActual arguments
Exceptions
\TYPO3\CMS\Fluid\Core\Parser\Exception

Definition at line 616 of file TemplateParser.php.

Referenced by TemplateParser\initializeViewHelperAndAddItToStack().

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
\TYPO3\CMS\Fluid\Core\Parser\Exception

Definition at line 595 of file TemplateParser.php.

Referenced by TemplateParser\initializeViewHelperAndAddItToStack().

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 912 of file TemplateParser.php.

Referenced by TemplateParser\textAndShorthandSyntaxHandler().

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 830 of file TemplateParser.php.

References TemplateParser\buildObjectTree(), and TemplateParser\splitTemplateAtDynamicTags().

Referenced by TemplateParser\parseArguments(), and TemplateParser\recursiveArrayHandler().

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.
int$contextone of the CONTEXT_* constants, defining whether we are inside or outside of ViewHelper arguments currently.
Returns
Exceptions
\TYPO3\CMS\Fluid\Core\Parser\Exception

Definition at line 494 of file TemplateParser.php.

References TemplateParser\closingViewHelperTagHandler(), elseif, TemplateParser\openingViewHelperTagHandler(), TemplateParser\prepareTemplateRegularExpression(), TemplateParser\textAndShorthandSyntaxHandler(), and TemplateParser\textHandler().

Referenced by TemplateParser\buildArgumentObjectTree(), and TemplateParser\parse().

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.
int$interceptionPointthe interception point. One of the ::INTERCEPT_* constants.
\TYPO3\CMS\Fluid\Core\Parser\ParsingState$statethe parsing state
Returns
void

Definition at line 760 of file TemplateParser.php.

Referenced by TemplateParser\closingViewHelperTagHandler(), TemplateParser\initializeViewHelperAndAddItToStack(), TemplateParser\objectAccessorHandler(), TemplateParser\openingViewHelperTagHandler(), and TemplateParser\textHandler().

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
\TYPO3\CMS\Fluid\Core\Parser\Exception

Definition at line 680 of file TemplateParser.php.

References TemplateParser\callInterceptor(), InterceptorInterface\INTERCEPT_CLOSING_VIEWHELPER, and TemplateParser\resolveViewHelperName().

Referenced by TemplateParser\buildObjectTree().

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
\TYPO3\CMS\Fluid\Core\Parser\Exceptionif a namespace can't be resolved or has been declared already

Definition at line 397 of file TemplateParser.php.

References TemplateParser\removeXmlnsViewHelperNamespaceDeclarations().

Referenced by TemplateParser\parse().

getNamespaces ( )

Gets the namespace definitions found.

Returns
array Namespace identifiers and their component name prefix

Definition at line 372 of file TemplateParser.php.

References TemplateParser\$namespaces.

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
\TYPO3\CMS\Fluid\Core\Parser\Exception

Definition at line 555 of file TemplateParser.php.

References TemplateParser\abortIfRequiredArgumentsAreMissing(), TemplateParser\abortIfUnregisteredArgumentsExist(), TemplateParser\callInterceptor(), InterceptorInterface\INTERCEPT_OPENING_VIEWHELPER, TemplateParser\resolveViewHelperName(), and TemplateParser\rewriteBooleanNodesInArgumentsObjectTree().

Referenced by TemplateParser\objectAccessorHandler(), and TemplateParser\openingViewHelperTagHandler().

injectSettings ( array  $settings)

Injects Fluid settings

Parameters
array$settings

Definition at line 319 of file TemplateParser.php.

References TemplateParser\$settings.

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 708 of file TemplateParser.php.

References TemplateParser\callInterceptor(), TemplateParser\initializeViewHelperAndAddItToStack(), InterceptorInterface\INTERCEPT_CLOSING_VIEWHELPER, InterceptorInterface\INTERCEPT_OBJECTACCESSOR, TemplateParser\postProcessArgumentsForObjectAccessor(), and TemplateParser\recursiveArrayHandler().

Referenced by TemplateParser\textAndShorthandSyntaxHandler().

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
bool$selfclosingtrue, if the tag is a self-closing tag.
Returns
void

Definition at line 533 of file TemplateParser.php.

References TemplateParser\callInterceptor(), TemplateParser\initializeViewHelperAndAddItToStack(), InterceptorInterface\INTERCEPT_CLOSING_VIEWHELPER, and TemplateParser\parseArguments().

Referenced by TemplateParser\buildObjectTree().

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
\TYPO3\CMS\Fluid\Core\Parser\Exception

Definition at line 347 of file TemplateParser.php.

References TemplateParser\buildObjectTree(), TemplateParser\extractNamespaceDefinitions(), TemplateParser\reset(), and TemplateParser\splitTemplateAtDynamicTags().

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 803 of file TemplateParser.php.

References TemplateParser\$configuration, TemplateParser\buildArgumentObjectTree(), and TemplateParser\unquoteString().

Referenced by TemplateParser\openingViewHelperTagHandler().

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 784 of file TemplateParser.php.

Referenced by TemplateParser\objectAccessorHandler().

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 872 of file TemplateParser.php.

Referenced by TemplateParser\buildObjectTree(), TemplateParser\splitTemplateAtDynamicTags(), and TemplateParser\textAndShorthandSyntaxHandler().

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
\TYPO3\CMS\Fluid\Core\Parser\Exception

Definition at line 933 of file TemplateParser.php.

References TemplateParser\buildArgumentObjectTree(), elseif, and TemplateParser\unquoteString().

Referenced by TemplateParser\objectAccessorHandler().

removeXmlnsViewHelperNamespaceDeclarations (   $templateString,
array  $foundIdentifiers 
)
protected

Removes html-tag (opening & closing) that is only used for xmlns definition and xmlns attributes that register ViewHelpers on any tags

Parameters
string$templateString
array$foundIdentifiers
Returns
string

Definition at line 449 of file TemplateParser.php.

Referenced by TemplateParser\extractNamespaceDefinitions().

reset ( )
protected

Resets the parser to its default values.

Returns
void

Definition at line 382 of file TemplateParser.php.

Referenced by TemplateParser\parse().

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 649 of file TemplateParser.php.

References Fluid\NAMESPACE_SEPARATOR.

Referenced by TemplateParser\closingViewHelperTagHandler(), and TemplateParser\initializeViewHelperAndAddItToStack().

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 633 of file TemplateParser.php.

Referenced by TemplateParser\initializeViewHelperAndAddItToStack().

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 330 of file TemplateParser.php.

References TemplateParser\$configuration.

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 480 of file TemplateParser.php.

References TemplateParser\prepareTemplateRegularExpression().

Referenced by TemplateParser\buildArgumentObjectTree(), and TemplateParser\parse().

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
int$contextone of the CONTEXT_* constants, defining whether we are inside or outside of ViewHelper arguments currently.
Returns
void

Definition at line 887 of file TemplateParser.php.

References TemplateParser\arrayHandler(), elseif, TemplateParser\objectAccessorHandler(), TemplateParser\prepareTemplateRegularExpression(), and TemplateParser\textHandler().

Referenced by TemplateParser\buildObjectTree().

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

Text node handler

Parameters
\TYPO3\CMS\Fluid\Core\Parser\ParsingState$state
string$text
Returns
void

Definition at line 966 of file TemplateParser.php.

References TemplateParser\callInterceptor(), and InterceptorInterface\INTERCEPT_TEXT.

Referenced by TemplateParser\buildObjectTree(), and TemplateParser\textAndShorthandSyntaxHandler().

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 849 of file TemplateParser.php.

Referenced by TemplateParser\parseArguments(), and TemplateParser\recursiveArrayHandler().

Member Data Documentation

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

Definition at line 270 of file TemplateParser.php.

Referenced by TemplateParser\getNamespaces().

$objectManager
protected

Definition at line 278 of file TemplateParser.php.

$SCAN_PATTERN_CDATA = '/^<!\\[CDATA\\[(.*?)\\]\\]>$/s'
static

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

Definition at line 128 of file TemplateParser.php.

$SCAN_PATTERN_DEFAULT_XML_NAMESPACE = '/^http\:\/\/typo3\.org\/ns\/(?P<PhpNamespace>.+)$/s'
static

This pattern detects the default xml namespace

Definition at line 264 of file TemplateParser.php.

$SCAN_PATTERN_NAMESPACE_FLUID_HTML_TAG = '/<html\\s++[^>]*data-namespace-typo3-fluid="true"[^>]*>/m'
static

This regular expression scans for HTML tags that have the attribute data-namespace-typo3-fluid="true". If this attribute is added to the HTML tag, the HTML tag will be removed from the rendered output.

Definition at line 91 of file TemplateParser.php.

$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_REMOVE_VIEWHELPERS_XMLNSDECLARATIONS = '/(?:\\s*+xmlns:(?:%1$s)="[^"]*"\\s*+)++/m'
static

This regular expression is used to remove xmlns attributes that are used to register ViewHelper namespaces.

Replaces trailing empty spaces to avoid additional new lines that might be in the the tag. It is therefore necessary to replace the pattern with space instead of empty string.

Searches for multiple xmlns declarations after one another to only replace them with one space, instead of one per xmlns definition.

Definition at line 103 of file TemplateParser.php.

Referenced by TemplateParserTest\removeXmlnsViewHelperNamespaceDeclarationsDataProvider().

$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 221 of file TemplateParser.php.

$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 155 of file TemplateParser.php.

$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.

Referenced by TemplateParserPatternTest\testSCAN_PATTERN_CLOSINGDYNAMICTAG().

$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.

Referenced by TemplateParserPatternTest\testSCAN_PATTERN_DYNAMICTAG().

$SCAN_PATTERN_XMLNSDECLARATION = '/\sxmlns:(?P<identifier>.*?)="(?P<xmlNamespace>.*?)"/m'
static

Definition at line 20 of file TemplateParser.php.

$settings
protected

Definition at line 288 of file TemplateParser.php.

Referenced by TemplateParser\injectSettings().

$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 134 of file TemplateParser.php.

Referenced by TemplateParserPatternTest\testSPLIT_PATTERN_SHORTHANDSYNTAX().

$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 244 of file TemplateParser.php.

$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 192 of file TemplateParser.php.

$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 108 of file TemplateParser.php.

$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.

Referenced by TemplateParserPatternTest\testSPLIT_PATTERN_DYNAMICTAGS().

$viewHelperNameToImplementationClassNameRuntimeCache = array()
protected

Definition at line 293 of file TemplateParser.php.

const 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.

Referenced by TemplateParserTest\textAndShorthandSyntaxHandlerDelegatesAppropriately().

const CONTEXT_OUTSIDE_VIEWHELPER_ARGUMENTS = 2