PHP Class Neos\Fusion\Core\Runtime

TypoScript Rendering Process ============================ During rendering, all TypoScript objects form a tree. When a TypoScript object at a certain $typoScriptPath is invoked, it has access to all variables stored in the $context (which is an array). The TypoScript object can then add or replace variables to this context using pushContext() or pushContextArray(), before rendering sub-TypoScript objects. After rendering these, it must call popContext() to reset the context to the last state.
Show file Open project: neos/neos-development-collection Class Usage Examples

Protected Properties

Property Type Description
$configurationOnPathRuntimeCache array
$controllerContext Neos\Flow\Mvc\Controller\ControllerContext
$debugMode boolean
$defaultContextVariables array Default context with helper definitions
$eelEvaluator Neos\Eel\CompilingEvaluator
$lastEvaluationStatus string
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
$renderingStack array Contains list of contexts
$runtimeContentCache Neos\Fusion\Core\Cache\RuntimeContentCache
$settings array
$simpleTypeToArrayClosure Closure
$typoScriptConfiguration array

Public Methods

Method Description
__construct ( array $typoScriptConfiguration, ControllerContext $controllerContext ) Constructor for the TypoScript Runtime
addCacheTag ( string $key, string $value ) : void Add a tag to the current cache segment
canRender ( string $typoScriptPath ) : boolean Determine if the given TypoScript path is renderable, which means it exists and has an implementation.
evaluate ( string $typoScriptPath, object $contextObject = null ) : mixed Evaluate an absolute TypoScript path and return the result
getControllerContext ( ) : ControllerContext Returns the context which has been passed by the currently active MVC Controller
getCurrentContext ( ) : array Get the current context array
getLastEvaluationStatus ( ) : string
handleRenderingException ( array $typoScriptPath, Exception $exception, boolean $useInnerExceptionHandler = false ) : string Handle an Exception thrown while rendering TypoScript according to settings specified in Neos.Fusion.rendering.exceptionHandler
injectSettings ( array $settings ) : void Inject settings of this package
isDebugMode ( ) : boolean
popContext ( ) : array Remove the topmost context objects and return them
pushContext ( string $key, mixed $context ) : void Push a new context object to the rendering stack
pushContextArray ( array $contextArray ) : void Completely replace the context array with the new $contextArray.
render ( string $typoScriptPath ) : string Render an absolute TypoScript path and return the result.
setDebugMode ( boolean $debugMode ) : void
setEnableContentCache ( boolean $flag ) : void If the TypoScript content cache should be enabled at all

Protected Methods

Method Description
canRenderWithConfiguration ( array $typoScriptConfiguration ) : boolean Internal evaluation if given configuration is renderable.
evaluateEelExpression ( string $expression, AbstractTypoScriptObject $contextObject = null ) : mixed Evaluate an Eel expression
evaluateEelExpressionOrSimpleValueWithProcessor ( string $typoScriptPath, array $valueConfiguration, AbstractTypoScriptObject $contextObject = null ) : mixed Evaluate a simple value or eel expression with processors
evaluateIfCondition ( array $configurationWithEventualIf, string $configurationPath, AbstractTypoScriptObject $contextObject = null ) : boolean Evaluate eventually existing meta "@if" conditionals inside the given configuration and path.
evaluateInternal ( string $typoScriptPath, string $behaviorIfPathNotFound, mixed $contextObject = null ) : mixed Internal evaluation method of absolute $typoScriptPath
evaluateObjectOrRetrieveFromCache ( AbstractTypoScriptObject $typoScriptObject, string $typoScriptPath, array $typoScriptConfiguration, array $cacheContext ) : mixed Does the evaluation of a TypoScript instance, first checking the cache and if conditions and afterwards applying processors.
evaluateProcessors ( mixed $valueToProcess, array $configurationWithEventualProcessors, string $typoScriptPath, AbstractTypoScriptObject $contextObject = null ) : mixed Evaluate processors on given value.
evaluteExpressionOrValueInternal ( string $typoScriptPath, array $typoScriptConfiguration, array $cacheContext, mixed $contextObject ) : mixed Evaluates an EEL expression or value, checking if conditions first and applying processors.
finalizePathEvaluation ( array $cacheContext, boolean $needToPopContext = false ) : void Ends the evaluation of a typoscript path by popping the context stack if needed and leaving the cache context.
getConfigurationForPath ( string $typoScriptPath ) : array Get the TypoScript Configuration for the given TypoScript path
getDefaultContextVariables ( ) : array Get variables from configuration that should be set in the context by default.
hasExpressionOrValue ( array $typoScriptConfiguration ) : boolean Does the given TypoScript configuration array hold an EEL expression or simple value.
instantiateTypoScriptObject ( string $typoScriptPath, array $typoScriptConfiguration ) : AbstractTypoScriptObject Instantiates a TypoScript object specified by the given path and configuration
isArrayTypoScriptObject ( AbstractTypoScriptObject $typoScriptObject ) : boolean Check if the given object is an array like object that should get all properties set to iterate or process internally.
matchCurrentPathPart ( string $pathPart, array $previousConfiguration, array &$currentPrototypeDefinitions ) : array Matches the current path segment and prepares the configuration.
mergePrototypesWithConfigurationForPathSegment ( array $configuration, array &$currentPrototypeDefinitions ) : array Merges the prototype chain into the configuration.
prepareContextForTypoScriptObject ( AbstractTypoScriptObject $typoScriptObject, string $typoScriptPath, array $typoScriptConfiguration, array $cacheContext ) : boolean Possibly prepares a new context for the current TypoScriptObject and cache context and pushes it to the stack.
setPropertiesOnTypoScriptObject ( AbstractArrayTypoScriptObject $typoScriptObject, array $typoScriptConfiguration ) : void Set options on the given (AbstractArray)TypoScript object
throwExceptionForUnrenderablePathIfNeeded ( string $typoScriptPath, array $typoScriptConfiguration, string $behaviorIfPathNotFound ) Checks and throws an exception for an unrenderable path.

Method Details

__construct() public method

Constructor for the TypoScript Runtime
public __construct ( array $typoScriptConfiguration, ControllerContext $controllerContext )
$typoScriptConfiguration array
$controllerContext Neos\Flow\Mvc\Controller\ControllerContext

addCacheTag() public method

During TS rendering the method can be used to add tag dynamicaly for the current cache segment.
public addCacheTag ( string $key, string $value ) : void
$key string
$value string
return void

canRender() public method

Determine if the given TypoScript path is renderable, which means it exists and has an implementation.
public canRender ( string $typoScriptPath ) : boolean
$typoScriptPath string
return boolean

canRenderWithConfiguration() protected method

Internal evaluation if given configuration is renderable.
protected canRenderWithConfiguration ( array $typoScriptConfiguration ) : boolean
$typoScriptConfiguration array
return boolean

evaluate() public method

Evaluate an absolute TypoScript path and return the result
public evaluate ( string $typoScriptPath, object $contextObject = null ) : mixed
$typoScriptPath string
$contextObject object the object available as "this" in Eel expressions. ONLY FOR INTERNAL USE!
return mixed the result of the evaluation, can be a string but also other data types

evaluateEelExpression() protected method

Evaluate an Eel expression
protected evaluateEelExpression ( string $expression, AbstractTypoScriptObject $contextObject = null ) : mixed
$expression string The Eel expression to evaluate
$contextObject Neos\Fusion\TypoScriptObjects\AbstractTypoScriptObject An optional object for the "this" value inside the context
return mixed The result of the evaluated Eel expression

evaluateEelExpressionOrSimpleValueWithProcessor() protected method

Evaluate a simple value or eel expression with processors
protected evaluateEelExpressionOrSimpleValueWithProcessor ( string $typoScriptPath, array $valueConfiguration, AbstractTypoScriptObject $contextObject = null ) : mixed
$typoScriptPath string the TypoScript path up to now
$valueConfiguration array TypoScript configuration for the value
$contextObject Neos\Fusion\TypoScriptObjects\AbstractTypoScriptObject An optional object for the "this" value inside the context
return mixed The result of the evaluation

evaluateIfCondition() protected method

Evaluate eventually existing meta "@if" conditionals inside the given configuration and path.
protected evaluateIfCondition ( array $configurationWithEventualIf, string $configurationPath, AbstractTypoScriptObject $contextObject = null ) : boolean
$configurationWithEventualIf array
$configurationPath string
$contextObject Neos\Fusion\TypoScriptObjects\AbstractTypoScriptObject
return boolean

evaluateInternal() protected method

Internal evaluation method of absolute $typoScriptPath
protected evaluateInternal ( string $typoScriptPath, string $behaviorIfPathNotFound, mixed $contextObject = null ) : mixed
$typoScriptPath string
$behaviorIfPathNotFound string one of BEHAVIOR_EXCEPTION or BEHAVIOR_RETURNNULL
$contextObject mixed the object which will be "this" in Eel expressions, if any
return mixed

evaluateObjectOrRetrieveFromCache() protected method

Does the evaluation of a TypoScript instance, first checking the cache and if conditions and afterwards applying processors.
protected evaluateObjectOrRetrieveFromCache ( AbstractTypoScriptObject $typoScriptObject, string $typoScriptPath, array $typoScriptConfiguration, array $cacheContext ) : mixed
$typoScriptObject Neos\Fusion\TypoScriptObjects\AbstractTypoScriptObject
$typoScriptPath string
$typoScriptConfiguration array
$cacheContext array
return mixed

evaluateProcessors() protected method

Evaluate processors on given value.
protected evaluateProcessors ( mixed $valueToProcess, array $configurationWithEventualProcessors, string $typoScriptPath, AbstractTypoScriptObject $contextObject = null ) : mixed
$valueToProcess mixed
$configurationWithEventualProcessors array
$typoScriptPath string
$contextObject Neos\Fusion\TypoScriptObjects\AbstractTypoScriptObject
return mixed

evaluteExpressionOrValueInternal() protected method

Evaluates an EEL expression or value, checking if conditions first and applying processors.
protected evaluteExpressionOrValueInternal ( string $typoScriptPath, array $typoScriptConfiguration, array $cacheContext, mixed $contextObject ) : mixed
$typoScriptPath string
$typoScriptConfiguration array
$cacheContext array
$contextObject mixed
return mixed

finalizePathEvaluation() protected method

Ends the evaluation of a typoscript path by popping the context stack if needed and leaving the cache context.
protected finalizePathEvaluation ( array $cacheContext, boolean $needToPopContext = false ) : void
$cacheContext array
$needToPopContext boolean
return void

getConfigurationForPath() protected method

Get the TypoScript Configuration for the given TypoScript path
protected getConfigurationForPath ( string $typoScriptPath ) : array
$typoScriptPath string
return array

getControllerContext() public method

Returns the context which has been passed by the currently active MVC Controller
public getControllerContext ( ) : ControllerContext
return Neos\Flow\Mvc\Controller\ControllerContext

getCurrentContext() public method

Get the current context array
public getCurrentContext ( ) : array
return array the array of current context objects

getDefaultContextVariables() protected method

For example Eel helpers are made available by this.
protected getDefaultContextVariables ( ) : array
return array Array with default context variable objects.

getLastEvaluationStatus() public method

public getLastEvaluationStatus ( ) : string
return string

handleRenderingException() public method

Handle an Exception thrown while rendering TypoScript according to settings specified in Neos.Fusion.rendering.exceptionHandler
public handleRenderingException ( array $typoScriptPath, Exception $exception, boolean $useInnerExceptionHandler = false ) : string
$typoScriptPath array
$exception Exception
$useInnerExceptionHandler boolean
return string

hasExpressionOrValue() protected method

Does the given TypoScript configuration array hold an EEL expression or simple value.
protected hasExpressionOrValue ( array $typoScriptConfiguration ) : boolean
$typoScriptConfiguration array
return boolean

injectSettings() public method

Inject settings of this package
public injectSettings ( array $settings ) : void
$settings array The settings
return void

instantiateTypoScriptObject() protected method

Instantiates a TypoScript object specified by the given path and configuration
protected instantiateTypoScriptObject ( string $typoScriptPath, array $typoScriptConfiguration ) : AbstractTypoScriptObject
$typoScriptPath string Path to the configuration for this object instance
$typoScriptConfiguration array Configuration at the given path
return Neos\Fusion\TypoScriptObjects\AbstractTypoScriptObject

isArrayTypoScriptObject() protected method

Check if the given object is an array like object that should get all properties set to iterate or process internally.
protected isArrayTypoScriptObject ( AbstractTypoScriptObject $typoScriptObject ) : boolean
$typoScriptObject Neos\Fusion\TypoScriptObjects\AbstractTypoScriptObject
return boolean

isDebugMode() public method

public isDebugMode ( ) : boolean
return boolean

matchCurrentPathPart() protected method

Matches the current path segment and prepares the configuration.
protected matchCurrentPathPart ( string $pathPart, array $previousConfiguration, array &$currentPrototypeDefinitions ) : array
$pathPart string
$previousConfiguration array
$currentPrototypeDefinitions array
return array

mergePrototypesWithConfigurationForPathSegment() protected method

Merges the prototype chain into the configuration.
protected mergePrototypesWithConfigurationForPathSegment ( array $configuration, array &$currentPrototypeDefinitions ) : array
$configuration array
$currentPrototypeDefinitions array
return array

popContext() public method

Remove the topmost context objects and return them
public popContext ( ) : array
return array the topmost context objects as associative array

prepareContextForTypoScriptObject() protected method

Returns if a new context was pushed to the stack or not.
protected prepareContextForTypoScriptObject ( AbstractTypoScriptObject $typoScriptObject, string $typoScriptPath, array $typoScriptConfiguration, array $cacheContext ) : boolean
$typoScriptObject Neos\Fusion\TypoScriptObjects\AbstractTypoScriptObject
$typoScriptPath string
$typoScriptConfiguration array
$cacheContext array
return boolean

pushContext() public method

Push a new context object to the rendering stack
public pushContext ( string $key, mixed $context ) : void
$key string the key inside the context
$context mixed
return void

pushContextArray() public method

Purely internal method, should not be called outside of Neos.Fusion.
public pushContextArray ( array $contextArray ) : void
$contextArray array
return void

render() public method

Compared to $this->evaluate, this adds some more comments helpful for debugging.
public render ( string $typoScriptPath ) : string
$typoScriptPath string
return string

setDebugMode() public method

public setDebugMode ( boolean $debugMode ) : void
$debugMode boolean
return void

setEnableContentCache() public method

If the TypoScript content cache should be enabled at all
public setEnableContentCache ( boolean $flag ) : void
$flag boolean
return void

setPropertiesOnTypoScriptObject() protected method

Set options on the given (AbstractArray)TypoScript object
protected setPropertiesOnTypoScriptObject ( AbstractArrayTypoScriptObject $typoScriptObject, array $typoScriptConfiguration ) : void
$typoScriptObject Neos\Fusion\TypoScriptObjects\AbstractArrayTypoScriptObject
$typoScriptConfiguration array
return void

throwExceptionForUnrenderablePathIfNeeded() protected method

Checks and throws an exception for an unrenderable path.
protected throwExceptionForUnrenderablePathIfNeeded ( string $typoScriptPath, array $typoScriptConfiguration, string $behaviorIfPathNotFound )
$typoScriptPath string The TypoScript path that cannot be rendered
$typoScriptConfiguration array
$behaviorIfPathNotFound string One of the BEHAVIOR_* constants

Property Details

$configurationOnPathRuntimeCache protected property

protected array $configurationOnPathRuntimeCache
return array

$controllerContext protected property

protected ControllerContext,Neos\Flow\Mvc\Controller $controllerContext
return Neos\Flow\Mvc\Controller\ControllerContext

$debugMode protected property

protected bool $debugMode
return boolean

$defaultContextVariables protected property

Default context with helper definitions
protected array $defaultContextVariables
return array

$eelEvaluator protected property

protected CompilingEvaluator,Neos\Eel $eelEvaluator
return Neos\Eel\CompilingEvaluator

$lastEvaluationStatus protected property

protected string $lastEvaluationStatus
return string

$objectManager protected property

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

$renderingStack protected property

Contains list of contexts
protected array $renderingStack
return array

$runtimeContentCache protected property

protected RuntimeContentCache,Neos\Fusion\Core\Cache $runtimeContentCache
return Neos\Fusion\Core\Cache\RuntimeContentCache

$settings protected property

protected array $settings
return array

$simpleTypeToArrayClosure protected property

protected Closure $simpleTypeToArrayClosure
return Closure

$typoScriptConfiguration protected property

protected array $typoScriptConfiguration
return array