class Runtime (View source)

Fusion Runtime

Fusion Rendering Process

During rendering, all Fusion objects form a tree.

When a Fusion object at a certain $fusionPath is invoked, it has access to all variables stored in the $context (which is an array).

The Fusion object can then add or replace variables to this context using pushContext() or pushContextArray(), before rendering sub-Fusion objects. After rendering these, it must call popContext() to reset the context to the last state.

Constants

BEHAVIOR_EXCEPTION

Internal constants defining how evaluate should work in case of an error

BEHAVIOR_RETURNNULL

EVALUATION_EXECUTED

Internal constants defining a status of how evaluate was evaluated

EVALUATION_SKIPPED

Properties

protected CompilingEvaluator $eelEvaluator
protected ObjectManagerInterface $objectManager
protected array $contextStack

Stack of evaluated "@context" values

protected array $currentContext

Reference to the current context

protected array $currentApplyValues

Reference to the current apply value

protected array $defaultContextVariables

Default context with helper definitions

protected array $runtimeConfiguration
protected ControllerContext $controllerContext
protected array $settings
protected bool $debugMode
protected RuntimeContentCache $runtimeContentCache
protected string $lastEvaluationStatus

Methods

__construct(array $fusionConfiguration, ControllerContext $controllerContext)

Constructor for the Fusion Runtime

void
injectSettings(array $settings)

Inject settings of this package

void
addCacheTag(string $key, string $value)

Add a tag to the current cache segment

void
pushContextArray(array $contextArray)

Completely replace the context array with the new $contextArray.

void
pushContext(string $key, mixed $context)

Push a new context object to the rendering stack

array
popContext()

Remove the topmost context objects and return them

array
getCurrentContext()

Get the current context array

void
popApplyValues(array $paths)

No description

string
getLastEvaluationStatus()

No description

mixed
render(string $fusionPath)

Render an absolute Fusion path and return the result.

string
handleRenderingException(string $fusionPath, Exception $exception, bool $useInnerExceptionHandler = false)

Handle an Exception thrown while rendering Fusion according to settings specified in Neos.Fusion.rendering.exceptionHandler

bool
canRender(string $fusionPath)

Determine if the given Fusion path is renderable, which means it exists and has an implementation.

mixed
evaluate(string $fusionPath, mixed $contextObject = null, string $behaviorIfPathNotFound = self::BEHAVIOR_RETURNNULL)

Evaluate an absolute Fusion path and return the result

mixed
evaluateObjectOrRetrieveFromCache(AbstractFusionObject $fusionObject, string $fusionPath, array $fusionConfiguration, array $cacheContext)

Does the evaluation of a Fusion instance, first checking the cache and if conditions and afterwards applying processors.

mixed
evaluateExpressionOrValueInternal(string $fusionPath, array $fusionConfiguration, AbstractFusionObject $contextObject)

Evaluates an EEL expression or value, checking if conditions first and applying processors.

array
prepareApplyValuesForFusionPath(string $fusionPath, array $fusionConfiguration)

Possibly prepares a new "@apply" context for the current fusionPath and pushes it to the stack.

bool
prepareContextForFusionObject(AbstractFusionObject $fusionObject, string $fusionPath, array $fusionConfiguration, array $cacheContext)

Possibly prepares a new context for the current FusionObject and cache context and pushes it to the stack.

void
finalizePathEvaluation(array $cacheContext, bool $needToPopContext = false, array $applyPathsToPop = [])

Ends the evaluation of a fusion path by popping the context and property stack if needed and leaving the cache context.

instantiateFusionObject(string $fusionPath, array $fusionConfiguration, array $applyValuePaths)

Instantiates a Fusion object specified by the given path and configuration

bool
isArrayFusionObject(AbstractFusionObject $fusionObject)

Check if the given object is an array like object that should get all properties set to iterate or process internally.

void
setPropertiesOnFusionObject(AbstractArrayFusionObject $fusionObject, array $fusionConfiguration, array $applyValuePaths)

Set options on the given (AbstractArray)Fusion object

mixed
evaluateEelExpression(string $expression, AbstractFusionObject $contextObject = null)

Evaluate an Eel expression

array|null
evaluateApplyValues(array $configurationWithEventualProperties, string $fusionPath)

Evaluate "@apply" for the given fusion key.

mixed
evaluateProcessors(mixed $valueToProcess, array $configurationWithEventualProcessors, string $fusionPath, AbstractFusionObject $contextObject = null)

Evaluate processors on given value.

bool
evaluateIfCondition(array $configurationWithEventualIf, string $configurationPath, AbstractFusionObject $contextObject = null)

Evaluate eventually existing meta "@if" conditionals inside the given configuration and path.

ControllerContext
getControllerContext()

Returns the context which has been passed by the currently active MVC Controller

array
getDefaultContextVariables()

Get variables from configuration that should be set in the context by default.

throwExceptionForUnrenderablePathIfNeeded(string $fusionPath, array $fusionConfiguration, string $behaviorIfPathNotFound)

Checks and throws an exception for an unrenderable path.

void
setDebugMode(bool $debugMode)

No description

bool
isDebugMode()

No description

void
setEnableContentCache(bool $flag)

If the Fusion content cache should be enabled at all

Details

__construct(array $fusionConfiguration, ControllerContext $controllerContext)

Constructor for the Fusion Runtime

Parameters

array $fusionConfiguration
ControllerContext $controllerContext

void injectSettings(array $settings)

Inject settings of this package

Parameters

array $settings

The settings

Return Value

void

void addCacheTag(string $key, string $value)

Add a tag to the current cache segment

During Fusion rendering the method can be used to add tag dynamicaly for the current cache segment.

Parameters

string $key
string $value

Return Value

void

void pushContextArray(array $contextArray)

Completely replace the context array with the new $contextArray.

Purely internal method, should not be called outside of Neos.Fusion.

Parameters

array $contextArray

Return Value

void

void pushContext(string $key, mixed $context)

Push a new context object to the rendering stack

Parameters

string $key

the key inside the context

mixed $context

Return Value

void

array popContext()

Remove the topmost context objects and return them

Return Value

array

the topmost context objects as associative array

array getCurrentContext()

Get the current context array

Return Value

array

the array of current context objects

void popApplyValues(array $paths)

No description

Parameters

array $paths

Return Value

void

string getLastEvaluationStatus()

No description

Return Value

string

mixed render(string $fusionPath)

Render an absolute Fusion path and return the result.

Compared to $this->evaluate, this adds some more comments helpful for debugging.

Parameters

string $fusionPath

Return Value

mixed

Exceptions

Exception
Exception

string handleRenderingException(string $fusionPath, Exception $exception, bool $useInnerExceptionHandler = false)

Handle an Exception thrown while rendering Fusion according to settings specified in Neos.Fusion.rendering.exceptionHandler

Parameters

string $fusionPath
Exception $exception
bool $useInnerExceptionHandler

Return Value

string

Exceptions

Exception
InvalidConfigurationException
Exception
StopActionException

bool canRender(string $fusionPath)

Determine if the given Fusion path is renderable, which means it exists and has an implementation.

Parameters

string $fusionPath

Return Value

bool

Exceptions

Exception

mixed evaluate(string $fusionPath, mixed $contextObject = null, string $behaviorIfPathNotFound = self::BEHAVIOR_RETURNNULL)

Evaluate an absolute Fusion path and return the result

Parameters

string $fusionPath
mixed $contextObject

The object which will be "this" in Eel expressions. ONLY FOR INTERNAL USE!

string $behaviorIfPathNotFound

One of BEHAVIOR_EXCEPTION or BEHAVIOR_RETURNNULL

Return Value

mixed

Exceptions

StopActionException
Exception
Exception
RuntimeException
InvalidConfigurationException

protected mixed evaluateObjectOrRetrieveFromCache(AbstractFusionObject $fusionObject, string $fusionPath, array $fusionConfiguration, array $cacheContext)

Does the evaluation of a Fusion instance, first checking the cache and if conditions and afterwards applying processors.

Parameters

AbstractFusionObject $fusionObject
string $fusionPath
array $fusionConfiguration
array $cacheContext

Return Value

mixed

protected mixed evaluateExpressionOrValueInternal(string $fusionPath, array $fusionConfiguration, AbstractFusionObject $contextObject)

Evaluates an EEL expression or value, checking if conditions first and applying processors.

Parameters

string $fusionPath

the Fusion path up to now

array $fusionConfiguration

Fusion configuration for the expression or value

AbstractFusionObject $contextObject

An optional object for the "this" value inside the context

Return Value

mixed

The result of the evaluation

Exceptions

Exception

protected array prepareApplyValuesForFusionPath(string $fusionPath, array $fusionConfiguration)

Possibly prepares a new "@apply" context for the current fusionPath and pushes it to the stack.

Returns true to express that new properties were pushed and have to be popped during finalizePathEvaluation.

Since "@apply" are not inherited every call of this method leads to a completely new "@apply" context, which is null by default.

Parameters

string $fusionPath
array $fusionConfiguration

Return Value

array

Paths to pop

Exceptions

Exception
RuntimeException
Exception
StopActionException

protected bool prepareContextForFusionObject(AbstractFusionObject $fusionObject, string $fusionPath, array $fusionConfiguration, array $cacheContext)

Possibly prepares a new context for the current FusionObject and cache context and pushes it to the stack.

Returns if a new context was pushed to the stack or not.

Parameters

AbstractFusionObject $fusionObject
string $fusionPath
array $fusionConfiguration
array $cacheContext

Return Value

bool

Exceptions

Exception
RuntimeException
Exception
StopActionException

protected void finalizePathEvaluation(array $cacheContext, bool $needToPopContext = false, array $applyPathsToPop = [])

Ends the evaluation of a fusion path by popping the context and property stack if needed and leaving the cache context.

Parameters

array $cacheContext
bool $needToPopContext
array $applyPathsToPop

Return Value

void

protected AbstractFusionObject instantiateFusionObject(string $fusionPath, array $fusionConfiguration, array $applyValuePaths)

Instantiates a Fusion object specified by the given path and configuration

Parameters

string $fusionPath

Path to the configuration for this object instance

array $fusionConfiguration

Configuration at the given path

array $applyValuePaths

Apply value paths for this object

Return Value

AbstractFusionObject

Exceptions

Exception

protected bool isArrayFusionObject(AbstractFusionObject $fusionObject)

Check if the given object is an array like object that should get all properties set to iterate or process internally.

Parameters

AbstractFusionObject $fusionObject

Return Value

bool

protected void setPropertiesOnFusionObject(AbstractArrayFusionObject $fusionObject, array $fusionConfiguration, array $applyValuePaths)

Set options on the given (AbstractArray)Fusion object

Parameters

AbstractArrayFusionObject $fusionObject
array $fusionConfiguration
array $applyValuePaths

Return Value

void

protected mixed evaluateEelExpression(string $expression, AbstractFusionObject $contextObject = null)

Evaluate an Eel expression

Parameters

string $expression

The Eel expression to evaluate

AbstractFusionObject $contextObject

An optional object for the "this" value inside the context

Return Value

mixed

The result of the evaluated Eel expression

Exceptions

Exception

protected array|null evaluateApplyValues(array $configurationWithEventualProperties, string $fusionPath)

Evaluate "@apply" for the given fusion key.

If apply-definitions are found they are evaluated and the returned keys are combined. The result is returned as array with the following structure:

[ 'fusionPath/key_1' => ['key' => 'key_1', 'value' => 'evaluated value 1'], 'fusionPath/key_2' => ['key' => 'key_2', 'value' => 'evaluated value 2'] ]

If no apply-expression is defined null is returned instead.

Parameters

array $configurationWithEventualProperties
string $fusionPath

Return Value

array|null

protected mixed evaluateProcessors(mixed $valueToProcess, array $configurationWithEventualProcessors, string $fusionPath, AbstractFusionObject $contextObject = null)

Evaluate processors on given value.

Parameters

mixed $valueToProcess
array $configurationWithEventualProcessors
string $fusionPath
AbstractFusionObject $contextObject

Return Value

mixed

protected bool evaluateIfCondition(array $configurationWithEventualIf, string $configurationPath, AbstractFusionObject $contextObject = null)

Evaluate eventually existing meta "@if" conditionals inside the given configuration and path.

Parameters

array $configurationWithEventualIf
string $configurationPath
AbstractFusionObject $contextObject

Return Value

bool

ControllerContext getControllerContext()

Returns the context which has been passed by the currently active MVC Controller

Return Value

ControllerContext

protected array getDefaultContextVariables()

Get variables from configuration that should be set in the context by default.

For example Eel helpers are made available by this.

Return Value

array

Array with default context variable objects.

protected throwExceptionForUnrenderablePathIfNeeded(string $fusionPath, array $fusionConfiguration, string $behaviorIfPathNotFound)

Checks and throws an exception for an unrenderable path.

Parameters

string $fusionPath

The Fusion path that cannot be rendered

array $fusionConfiguration
string $behaviorIfPathNotFound

One of the BEHAVIOR_* constants

Exceptions

MissingFusionImplementationException
MissingFusionObjectException

void setDebugMode(bool $debugMode)

No description

Parameters

bool $debugMode

Return Value

void

bool isDebugMode()

No description

Return Value

bool

void setEnableContentCache(bool $flag)

If the Fusion content cache should be enabled at all

Parameters

bool $flag

Return Value

void