TYPO3
7.6
|
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 Attributes | |
$namespaces | |
$objectManager | |
$configuration | |
$settings | |
$viewHelperNameToImplementationClassNameRuntimeCache = array() | |
Template parser building up an object syntax tree
Definition at line 17 of file TemplateParser.php.
__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.
|
protected |
Throw an exception if required arguments are missing
array | $expectedArguments | Array of of all expected arguments |
array | $actualArguments | Actual arguments |
\TYPO3\CMS\Fluid\Core\Parser\Exception |
Definition at line 616 of file TemplateParser.php.
Referenced by TemplateParser\initializeViewHelperAndAddItToStack().
|
protected |
Throw an exception if there are arguments which were not registered before.
array | $expectedArguments | Array of of all expected arguments |
array | $actualArguments | Actual arguments |
\TYPO3\CMS\Fluid\Core\Parser\Exception |
Definition at line 595 of file TemplateParser.php.
Referenced by TemplateParser\initializeViewHelperAndAddItToStack().
|
protected |
Handler for array syntax. This creates the array object recursively and adds it to the current node.
\TYPO3\CMS\Fluid\Core\Parser\ParsingState | $state | The current parsing state |
string | $arrayText | The array as string. |
Definition at line 912 of file TemplateParser.php.
Referenced by TemplateParser\textAndShorthandSyntaxHandler().
|
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.
string | $argumentString |
Definition at line 830 of file TemplateParser.php.
References TemplateParser\buildObjectTree(), and TemplateParser\splitTemplateAtDynamicTags().
Referenced by TemplateParser\parseArguments(), and TemplateParser\recursiveArrayHandler().
|
protected |
Build object tree from the split template
array | $splitTemplate | The split template, so that every tag with a namespace declaration is already a separate array element. |
int | $context | one of the CONTEXT_* constants, defining whether we are inside or outside of ViewHelper arguments currently. |
\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().
|
protected |
Call all interceptors registered for a given interception point.
\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface | $node | The syntax tree node which can be modified by the interceptors. |
int | $interceptionPoint | the interception point. One of the ::INTERCEPT_* constants. |
\TYPO3\CMS\Fluid\Core\Parser\ParsingState | $state | the parsing state |
Definition at line 760 of file TemplateParser.php.
Referenced by TemplateParser\closingViewHelperTagHandler(), TemplateParser\initializeViewHelperAndAddItToStack(), TemplateParser\objectAccessorHandler(), TemplateParser\openingViewHelperTagHandler(), and TemplateParser\textHandler().
|
protected |
Handles a closing view helper tag
\TYPO3\CMS\Fluid\Core\Parser\ParsingState | $state | The current parsing state |
string | $namespaceIdentifier | Namespace identifier for the closing tag. |
string | $methodIdentifier | Method identifier. |
\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().
|
protected |
Extracts namespace definitions out of the given template string and sets $this->namespaces.
string | $templateString | Template string to extract the namespaces from |
\TYPO3\CMS\Fluid\Core\Parser\Exception | if 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.
Definition at line 372 of file TemplateParser.php.
References TemplateParser\$namespaces.
|
protected |
Initialize the given ViewHelper and adds it to the current node and to the stack.
\TYPO3\CMS\Fluid\Core\Parser\ParsingState | $state | Current parsing state |
string | $namespaceIdentifier | Namespace identifier - being looked up in $this->namespaces |
string | $methodIdentifier | Method identifier |
array | $argumentsObjectTree | Arguments object tree |
\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
array | $settings |
Definition at line 319 of file TemplateParser.php.
References TemplateParser\$settings.
|
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.
\TYPO3\CMS\Fluid\Core\Parser\ParsingState | $state | The current parsing state |
string | $objectAccessorString | String which identifies which objects to fetch |
string | $delimiter | |
string | $viewHelperString | |
string | $additionalViewHelpersString |
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().
|
protected |
Handles an opening or self-closing view helper tag.
\TYPO3\CMS\Fluid\Core\Parser\ParsingState | $state | Current parsing state |
string | $namespaceIdentifier | Namespace identifier - being looked up in $this->namespaces |
string | $methodIdentifier | Method identifier |
string | $arguments | Arguments string, not yet parsed |
bool | $selfclosing | true, if the tag is a self-closing tag. |
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.
string | $templateString | The template to parse as a string |
\TYPO3\CMS\Fluid\Core\Parser\Exception |
Definition at line 347 of file TemplateParser.php.
References TemplateParser\buildObjectTree(), TemplateParser\extractNamespaceDefinitions(), TemplateParser\reset(), and TemplateParser\splitTemplateAtDynamicTags().
|
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.
string | $argumentsString | All arguments as string |
Definition at line 803 of file TemplateParser.php.
References TemplateParser\$configuration, TemplateParser\buildArgumentObjectTree(), and TemplateParser\unquoteString().
Referenced by TemplateParser\openingViewHelperTagHandler().
|
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
array | $arguments | The arguments to be processed |
Definition at line 784 of file TemplateParser.php.
Referenced by TemplateParser\objectAccessorHandler().
|
protected |
Takes a regular expression template and replaces "NAMESPACE" with the currently registered namespace identifiers. Returns a regular expression which is ready to use.
string | $regularExpression | Regular expression template |
Definition at line 872 of file TemplateParser.php.
Referenced by TemplateParser\buildObjectTree(), TemplateParser\splitTemplateAtDynamicTags(), and TemplateParser\textAndShorthandSyntaxHandler().
|
protected |
Recursive function which takes the string representation of an array and builds an object tree from it.
Deals with the following value types:
string | $arrayText | Array text |
\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().
|
protected |
Removes html-tag (opening & closing) that is only used for xmlns definition and xmlns attributes that register ViewHelpers on any tags
string | $templateString | |
array | $foundIdentifiers |
Definition at line 449 of file TemplateParser.php.
Referenced by TemplateParser\extractNamespaceDefinitions().
|
protected |
Resets the parser to its default values.
Definition at line 382 of file TemplateParser.php.
Referenced by TemplateParser\parse().
|
protected |
Resolve a viewhelper name.
string | $namespaceIdentifier | Namespace identifier for the view helper. |
string | $methodIdentifier | Method identifier, might be hierarchical like "link.url" |
Definition at line 649 of file TemplateParser.php.
References Fluid\NAMESPACE_SEPARATOR.
Referenced by TemplateParser\closingViewHelperTagHandler(), and TemplateParser\initializeViewHelperAndAddItToStack().
|
protected |
Wraps the argument tree, if a node is boolean, into a Boolean syntax tree node
array | $argumentDefinitions | the argument definitions, key is the argument name, value is the ArgumentDefinition object |
array | $argumentsObjectTree | the arguments syntax tree, key is the argument name, value is an AbstractNode |
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.
\TYPO3\CMS\Fluid\Core\Parser\Configuration | $configuration |
Definition at line 330 of file TemplateParser.php.
References TemplateParser\$configuration.
|
protected |
Splits the template string on all dynamic tags found.
string | $templateString | Template string to split. |
Definition at line 480 of file TemplateParser.php.
References TemplateParser\prepareTemplateRegularExpression().
Referenced by TemplateParser\buildArgumentObjectTree(), and TemplateParser\parse().
|
protected |
Handler for everything which is not a ViewHelperNode.
This includes Text, array syntax, and object accessor syntax.
\TYPO3\CMS\Fluid\Core\Parser\ParsingState | $state | Current parsing state |
string | $text | Text to process |
int | $context | one of the CONTEXT_* constants, defining whether we are inside or outside of ViewHelper arguments currently. |
Definition at line 887 of file TemplateParser.php.
References TemplateParser\arrayHandler(), elseif, TemplateParser\objectAccessorHandler(), TemplateParser\prepareTemplateRegularExpression(), and TemplateParser\textHandler().
Referenced by TemplateParser\buildObjectTree().
|
protected |
Text node handler
\TYPO3\CMS\Fluid\Core\Parser\ParsingState | $state | |
string | $text |
Definition at line 966 of file TemplateParser.php.
References TemplateParser\callInterceptor(), and InterceptorInterface\INTERCEPT_TEXT.
Referenced by TemplateParser\buildObjectTree(), and TemplateParser\textAndShorthandSyntaxHandler().
|
protected |
Removes escapings from a given argument string and trims the outermost quotes.
This method is meant as a helper for regular expression results.
string | $quotedValue | Value to unquote |
Definition at line 849 of file TemplateParser.php.
Referenced by TemplateParser\parseArguments(), and TemplateParser\recursiveArrayHandler().
|
protected |
Definition at line 283 of file TemplateParser.php.
Referenced by TemplateParser\parseArguments(), and TemplateParser\setConfiguration().
|
protected |
Definition at line 270 of file TemplateParser.php.
Referenced by TemplateParser\getNamespaces().
|
protected |
Definition at line 278 of file TemplateParser.php.
|
static |
This pattern detects CDATA sections and outputs the text between opening and closing CDATA.
Definition at line 128 of file TemplateParser.php.
|
static |
This pattern detects the default xml namespace
Definition at line 264 of file TemplateParser.php.
|
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.
|
static |
Definition at line 19 of file TemplateParser.php.
Referenced by TemplateParserPatternTest\testSCAN_PATTERN_LEGACYNAMESPACEDECLARATION(), and TemplateParserPatternTest\testSCAN_PATTERN_NAMESPACEDECLARATION().
|
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().
|
static |
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.
|
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.
|
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().
|
static |
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().
|
static |
Definition at line 20 of file TemplateParser.php.
|
protected |
Definition at line 288 of file TemplateParser.php.
Referenced by TemplateParser\injectSettings().
|
static |
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().
|
static |
This pattern splits an array into its parts. It is quite similar to the pattern above.
Definition at line 244 of file TemplateParser.php.
|
static |
THIS IS ALMOST THE SAME AS $SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS
Definition at line 192 of file TemplateParser.php.
|
static |
This regular expression splits the tag arguments into its parts
Definition at line 108 of file TemplateParser.php.
|
static |
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().
|
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 |