PHP Class Neos\Fusion\Core\Parser

Inheritance: implements Neos\Fusion\Core\ParserInterface
Show file Open project: neos/neos-development-collection Class Usage Examples

Public Properties

Property Type Description
$reservedParseTreeKeys array Reserved parse tree keys for internal usage.

Protected Properties

Property Type Description
$contextPathAndFilename string An optional context path which is used as a prefix for inclusion of further TypoScript files
$currentBlockCommentState boolean Determines if a block comment is currently active or not.
$currentLineNumber integer The line number which is currently processed
$currentObjectPathStack array The current object path context as defined by confinements.
$currentSourceCodeLines array An array of strings of the source code which has
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
$objectTree array The TypoScript object tree, created by this parser.
$objectTypeNamespaces array By convention, the namespace should be a package key, but other strings would be possible, too. Note that, in order to resolve an object type, a prototype with that namespace and name must be defined elsewhere. These namespaces are _not_ used for resolution of processor class names.

Public Methods

Method Description
parse ( string $sourceCode, string $contextPathAndFilename = null, array $objectTreeUntilNow = [], boolean $buildPrototypeHierarchy = true ) : array Parses the given TypoScript source code and returns an object tree as the result.
setObjectTypeNamespace ( string $alias, string $namespace ) : void Sets the given alias to the specified namespace.

Protected Methods

Method Description
buildPrototypeHierarchy ( ) : void Precalculate merged configuration for inherited prototypes.
getCurrentObjectPathPrefix ( ) : string Returns the first part of an object path from the current object path stack which can be used to prefix a relative object path.
getNextTypoScriptLine ( ) : string Get the next, unparsed line of TypoScript from this->currentSourceCodeLines and increase the pointer
getParsedObjectPath ( string $objectPath ) : array Parse an object path specified as a string and returns an array.
getProcessedValue ( string $unparsedValue ) : mixed Parses the given value (which may be a literal, variable or object type) and returns the evaluated result, including variables replaced by their actual value.
getValueFromObjectTree ( array $objectPathArray, array &$objectTree = null ) : mixed Retrieves a value from a node in the object tree, specified by the object path array.
initialize ( ) : void Initializes the TypoScript parser
parseComment ( string $typoScriptLine ) : void Parses a line with comments or a line while parsing is in block comment mode.
parseConfinementBlock ( string $typoScriptLine, boolean $isOpeningConfinement ) : void Parses a line which opens or closes a confinement
parseDeclaration ( string $typoScriptLine ) : void Parses a parser declaration of the form "declarationtype: declaration".
parseInclude ( string $include ) : void Parse an include file. Currently, we start a new parser object; but we could as well re-use the given one.
parseNamespaceDeclaration ( string $namespaceDeclaration ) : void Parses a namespace declaration and stores the result in the namespace registry.
parseObjectDefinition ( string $typoScriptLine ) : void Parses an object definition.
parseTypoScriptLine ( string $typoScriptLine ) : void Parses one line of TypoScript
parseValueAssignment ( string $objectPath, string $value ) : void Parses a value operation of the type "assignment".
parseValueCopy ( string $sourceObjectPath, string $targetObjectPath ) : void Copies the object or value specified by sourcObjectPath and assigns it to targetObjectPath.
parseValueUnAssignment ( string $objectPath ) : void Unsets the object, property or variable specified by the object path.
setValueInObjectTree ( array $objectPathArray, mixed $value, array &$objectTree = null ) : array Assigns a value to a node or a property in the object tree, specified by the object path array.
unquoteString ( string $quotedValue ) : string Removes escapings from a given argument string and trims the outermost quotes.

Method Details

buildPrototypeHierarchy() protected method

Precalculate merged configuration for inherited prototypes.
protected buildPrototypeHierarchy ( ) : void
return void

getCurrentObjectPathPrefix() protected method

Returns the first part of an object path from the current object path stack which can be used to prefix a relative object path.
protected getCurrentObjectPathPrefix ( ) : string
return string A part of an object path, ready to use as a prefix

getNextTypoScriptLine() protected method

Get the next, unparsed line of TypoScript from this->currentSourceCodeLines and increase the pointer
protected getNextTypoScriptLine ( ) : string
return string next line of typoscript to parse

getParsedObjectPath() protected method

Parse an object path specified as a string and returns an array.
protected getParsedObjectPath ( string $objectPath ) : array
$objectPath string The object path to parse
return array An object path array

getProcessedValue() protected method

Parses the given value (which may be a literal, variable or object type) and returns the evaluated result, including variables replaced by their actual value.
protected getProcessedValue ( string $unparsedValue ) : mixed
$unparsedValue string The unparsed value
return mixed The processed value

getValueFromObjectTree() protected method

Retrieves a value from a node in the object tree, specified by the object path array.
protected getValueFromObjectTree ( array $objectPathArray, array &$objectTree = null ) : mixed
$objectPathArray array The object path, specifying the node to retrieve the value of
$objectTree array The current (sub-) tree, used internally - don't specify!
return mixed The value

initialize() protected method

Initializes the TypoScript parser
protected initialize ( ) : void
return void

parse() public method

Parses the given TypoScript source code and returns an object tree as the result.
public parse ( string $sourceCode, string $contextPathAndFilename = null, array $objectTreeUntilNow = [], boolean $buildPrototypeHierarchy = true ) : array
$sourceCode string The TypoScript source code to parse
$contextPathAndFilename string An optional path and filename to use as a prefix for inclusion of further TypoScript files
$objectTreeUntilNow array Used internally for keeping track of the built object tree
$buildPrototypeHierarchy boolean Merge prototype configurations or not. Will be FALSE for includes to only do that once at the end.
return array A TypoScript object tree, generated from the source code

parseComment() protected method

Parses a line with comments or a line while parsing is in block comment mode.
protected parseComment ( string $typoScriptLine ) : void
$typoScriptLine string One line of TypoScript code
return void

parseConfinementBlock() protected method

Parses a line which opens or closes a confinement
protected parseConfinementBlock ( string $typoScriptLine, boolean $isOpeningConfinement ) : void
$typoScriptLine string One line of TypoScript code
$isOpeningConfinement boolean Set to TRUE, if an opening confinement is to be parsed and FALSE if it's a closing confinement.
return void

parseDeclaration() protected method

Parses a parser declaration of the form "declarationtype: declaration".
protected parseDeclaration ( string $typoScriptLine ) : void
$typoScriptLine string One line of TypoScript code
return void

parseInclude() protected method

Parse an include file. Currently, we start a new parser object; but we could as well re-use the given one.
protected parseInclude ( string $include ) : void
$include string The include value, for example " FooBar" or " resource://....". Can also include wildcard mask for TypoScript globbing.
return void

parseNamespaceDeclaration() protected method

Parses a namespace declaration and stores the result in the namespace registry.
protected parseNamespaceDeclaration ( string $namespaceDeclaration ) : void
$namespaceDeclaration string The namespace declaration, for example "neos = Neos.Neos"
return void

parseObjectDefinition() protected method

Parses an object definition.
protected parseObjectDefinition ( string $typoScriptLine ) : void
$typoScriptLine string One line of TypoScript code
return void

parseTypoScriptLine() protected method

Parses one line of TypoScript
protected parseTypoScriptLine ( string $typoScriptLine ) : void
$typoScriptLine string One line of TypoScript code
return void

parseValueAssignment() protected method

Parses a value operation of the type "assignment".
protected parseValueAssignment ( string $objectPath, string $value ) : void
$objectPath string The object path as a string
$value string The unparsed value as a string
return void

parseValueCopy() protected method

Copies the object or value specified by sourcObjectPath and assigns it to targetObjectPath.
protected parseValueCopy ( string $sourceObjectPath, string $targetObjectPath ) : void
$sourceObjectPath string Specifies the location in the object tree from where the object or value will be taken
$targetObjectPath string Specifies the location in the object tree where the copy will be stored
return void

parseValueUnAssignment() protected method

Unsets the object, property or variable specified by the object path.
protected parseValueUnAssignment ( string $objectPath ) : void
$objectPath string The object path as a string
return void

setObjectTypeNamespace() public method

The namespaces defined through this setter or through a "namespace" declaration in one of the TypoScripts are used to resolve a fully qualified TypoScript object name while parsing TypoScript code. The alias is the handle by wich the namespace can be referred to. The namespace is, by convention, a package key which must correspond to a namespace used in the prototype definitions for TypoScript object types. The special alias "default" is used as a fallback for resolution of unqualified TypoScript object types.
public setObjectTypeNamespace ( string $alias, string $namespace ) : void
$alias string An alias for the given namespace, for example "neos"
$namespace string The namespace, for example "Neos.Neos"
return void

setValueInObjectTree() protected method

Assigns a value to a node or a property in the object tree, specified by the object path array.
protected setValueInObjectTree ( array $objectPathArray, mixed $value, array &$objectTree = null ) : array
$objectPathArray array The object path, specifying the node / property to set
$value mixed The value to assign, is a non-array type or an array with __eelExpression etc.
$objectTree array The current (sub-) tree, used internally - don't specify!
return array The modified object tree

unquoteString() protected method

This method is meant as a helper for regular expression results.
protected unquoteString ( string $quotedValue ) : string
$quotedValue string Value to unquote
return string Unquoted value

Property Details

$contextPathAndFilename protected property

An optional context path which is used as a prefix for inclusion of further TypoScript files
protected string $contextPathAndFilename
return string

$currentBlockCommentState protected property

Determines if a block comment is currently active or not.
protected bool $currentBlockCommentState
return boolean

$currentLineNumber protected property

The line number which is currently processed
protected int $currentLineNumber
return integer

$currentObjectPathStack protected property

The current object path context as defined by confinements.
protected array $currentObjectPathStack
return array

$currentSourceCodeLines protected property

An array of strings of the source code which has
protected array $currentSourceCodeLines
return array

$objectManager protected property

protected ObjectManagerInterface,Neos\Flow\ObjectManagement $objectManager
return Neos\Flow\ObjectManagement\ObjectManagerInterface

$objectTree protected property

The TypoScript object tree, created by this parser.
protected array $objectTree
return array

$objectTypeNamespaces protected property

By convention, the namespace should be a package key, but other strings would be possible, too. Note that, in order to resolve an object type, a prototype with that namespace and name must be defined elsewhere. These namespaces are _not_ used for resolution of processor class names.
protected array $objectTypeNamespaces
return array

$reservedParseTreeKeys public static property

Reserved parse tree keys for internal usage.
public static array $reservedParseTreeKeys
return array