public static function evaluateEelExpression($expression, EelEvaluatorInterface $eelEvaluator, array $contextVariables, array $defaultContextConfiguration = [])
{
$matches = null;
if (!preg_match(Package::EelExpressionRecognizer, $expression, $matches)) {
throw new Exception('The EEL expression "' . $expression . '" was not a valid EEL expression. Perhaps you forgot to wrap it in ${...}?', 1410441849);
}
$defaultContextVariables = self::getDefaultContextVariables($defaultContextConfiguration);
$contextVariables = array_merge($defaultContextVariables, $contextVariables);
if (isset($contextVariables['q'])) {
throw new Exception('Context variable "q" not allowed, as it is already reserved for FlowQuery use.', 1410441819);
}
$contextVariables['q'] = function ($element) {
return new FlowQuery\FlowQuery(is_array($element) || $element instanceof \Traversable ? $element : [$element]);
};
$context = new ProtectedContext($contextVariables);
$context->whitelist('q');
return $eelEvaluator->evaluate($matches['exp'], $context);
}