/** * Evaluate an Eel expression * * @param string $expression The Eel expression to evaluate * @param \Neos\Fusion\TypoScriptObjects\AbstractTypoScriptObject $contextObject An optional object for the "this" value inside the context * @return mixed The result of the evaluated Eel expression * @throws Exception */ protected function evaluateEelExpression($expression, AbstractTypoScriptObject $contextObject = null) { if ($expression[0] !== '$' || $expression[1] !== '{') { // We still assume this is an EEL expression and wrap the markers for backwards compatibility. $expression = '${' . $expression . '}'; } $contextVariables = array_merge($this->getDefaultContextVariables(), $this->getCurrentContext()); if (isset($contextVariables['this'])) { throw new Exception('Context variable "this" not allowed, as it is already reserved for a pointer to the current TypoScript object.', 1344325044); } $contextVariables['this'] = $contextObject; if ($this->eelEvaluator instanceof \Neos\Flow\ObjectManagement\DependencyInjection\DependencyProxy) { $this->eelEvaluator->_activateDependency(); } return EelUtility::evaluateEelExpression($expression, $this->eelEvaluator, $contextVariables); }