Runtime
class Runtime (View source)
| internal | The Fusion Runtime is considered internal. For interacting with Fusion from the outside a FusionView should be used. But custom Fusion object implementations might rely on manipulating/calling the Runtime directly, if the abstractions in the AbstractFusionObject doesn't suffice. TODO For that use case we should implement a more powerful and clean abstraction: https://github.com/neos/neos-development-collection/issues/4910 |
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.
Traits
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 |
|
| FusionGlobals | $fusionGlobals | Fusion global variables like EEL helper definitions {FusionGlobals} |
|
| protected RuntimeConfiguration | $runtimeConfiguration | ||
| protected array | $settings | ||
| protected bool | $debugMode | ||
| protected RuntimeContentCache | $runtimeContentCache | ||
| protected string | $lastEvaluationStatus | ||
| protected AbstractRenderingExceptionHandler|null | $overriddenExceptionHandler | {Runtime::overrideExceptionHandler} |
Methods
Inject settings of this package
Add a tag to the current cache segment
Completely replace the context array with the new $contextArray.
Push a new context object to the rendering stack.
Remove the topmost context objects and return them
Get the current context array.
No description
No description
Entry point to render a Fusion path with the context.
Render an absolute Fusion path and return the result.
Handle an Exception thrown while rendering Fusion according to settings specified in Neos.Fusion.rendering.exceptionHandler or {@exceptionHandler}
Determine if the given Fusion path is renderable, which means it exists and has an implementation.
Evaluate an absolute Fusion path and return the result
Does the evaluation of a Fusion instance, first checking the cache and if conditions and afterwards applying processors.
Evaluates an EEL expression or value, checking if conditions first and applying processors.
Possibly prepares a new "@apply" context for the current fusionPath and pushes it to the stack.
Possibly prepares a new context for the current FusionObject and cache context and pushes it to the stack.
Instantiates a Fusion object specified by the given path and configuration
Is the given object an array like object that should get all properties assigned to iterate or process internally
Assigns paths to the Array-Fusion object
Evaluate an Eel expression
Evaluate "@apply" for the given fusion key.
Evaluate processors on given value.
Evaluate eventually existing meta "@if" conditionals inside the given configuration and path.
Checks and throws an exception for an unrenderable path.
The concept of the controller context inside Fusion has been deprecated.
Configures this runtime to override the default exception handler configured in the settings or via Fusion's \@exceptionHandler {AbstractRenderingExceptionHandler}.
No description
No description
If the Fusion content cache should be enabled at all
Details
__construct(FusionConfiguration $fusionConfiguration, FusionGlobals $fusionGlobals)
| internal | the {@see \Neos\Fusion\Core\RuntimeFactory} must be used for instantiating, to make the EEL helpers available. |
No description
void
injectSettings(array $settings)
Inject settings of this package
void
addCacheTag(string $tag)
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.
void
pushContextArray(array $contextArray)
| internal | purely internal method, should not be called outside Neos.Fusion. |
Completely replace the context array with the new $contextArray.
Warning unlike in Fusion's \@context or {\Neos\Fusion\Core\Runtime::pushContext()}, no checks are imposed to prevent overriding Fusion globals like "request". Relying on this behaviour is highly discouraged but leveraged by Neos.Fusion.Form {\Neos\Fusion\Core\FusionGlobals}.
void
pushContext(string $key, mixed $context)
Push a new context object to the rendering stack.
It is disallowed to replace global variables {\Neos\Fusion\Core\FusionGlobals}.
array
popContext()
Remove the topmost context objects and return them
array
getCurrentContext()
Get the current context array.
This PHP context api unlike Fusion, doesn't include the Fusion globals {\Neos\Fusion\Core\FusionGlobals}. The globals can be accessed via {\Neos\Fusion\Core\Runtime::$fusionGlobals}.
void
popApplyValues(array $paths)
No description
string
getLastEvaluationStatus()
No description
ResponseInterface|StreamInterface
renderEntryPathWithContext(string $entryFusionPath, array $contextVariables)
Entry point to render a Fusion path with the context.
A ResponseInterface will be returned, if a Neos.Fusion:Http.Message was defined in the entry path, or if Neos.Fusion.Form or Neos.Neos:Plugin were used in the path.
In all other simple cases a StreamInterface will be returned.
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.
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 or {@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
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.
protected mixed
evaluateExpressionOrValueInternal(string $fusionPath, array $fusionConfiguration, AbstractFusionObject $contextObject)
Evaluates an EEL expression or value, checking if conditions first and applying processors.
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.
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.
protected AbstractFusionObject
instantiateFusionObject(string $fusionPath, array $fusionConfiguration, array $applyValuePaths)
Instantiates a Fusion object specified by the given path and configuration
protected bool
shouldAssignPropertiesToFusionObject(AbstractFusionObject $fusionObject)
Is the given object an array like object that should get all properties assigned to iterate or process internally
protected void
assignPropertiesToFusionObject(AbstractArrayFusionObject $fusionObject, array $fusionConfiguration, array $applyValuePaths)
Assigns paths to the Array-Fusion object
protected mixed
evaluateEelExpression(string $expression, AbstractFusionObject|null $contextObject = null)
Evaluate an Eel expression
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.
protected mixed
evaluateProcessors(mixed $valueToProcess, array $configurationWithEventualProcessors, string $fusionPath, AbstractFusionObject|null $contextObject = null)
Evaluate processors on given value.
protected bool
evaluateIfCondition(array $configurationWithEventualIf, string $configurationPath, AbstractFusionObject|null $contextObject = null)
Evaluate eventually existing meta "@if" conditionals inside the given configuration and path.
protected void
throwExceptionForUnrenderablePathIfNeeded(string $fusionPath, array $fusionConfiguration, string $behaviorIfPathNotFound)
Checks and throws an exception for an unrenderable path.
LegacyFusionControllerContext
getControllerContext()
deprecated
deprecated
| internal |
The concept of the controller context inside Fusion has been deprecated.
For further information and migration strategies, please look into {\Neos\Fusion\Core\LegacyFusionControllerContext}
WARNING:
Invoking this backwards-compatible layer is possibly unsafe, if the rendering was not started
in {\Neos\Fusion\Core\self::renderEntryPathWithContext()} or no request global is available. This will raise an exception.
void
overrideExceptionHandler(AbstractRenderingExceptionHandler $exceptionHandler)
Configures this runtime to override the default exception handler configured in the settings or via Fusion's \@exceptionHandler {AbstractRenderingExceptionHandler}.
In combination with the throwing handler {\Neos\Fusion\Core\ExceptionHandlers\ThrowingHandler} this can be used to rethrow all exceptions. This is helpfully for renderings in CLI context or testing.
void
setDebugMode(bool $debugMode)
No description
bool
isDebugMode()
No description
void
setEnableContentCache(bool $flag)
If the Fusion content cache should be enabled at all