evaluateEelExpression() public static méthode

Evaluate an Eel expression.
public static evaluateEelExpression ( string $expression, Neos\Eel\EelEvaluatorInterface $eelEvaluator, array $contextVariables, array $defaultContextConfiguration = [] ) : mixed
$expression string
$eelEvaluator Neos\Eel\EelEvaluatorInterface
$contextVariables array
$defaultContextConfiguration array
Résultat mixed
 /**
  * Render a node label
  *
  * @param NodeInterface $node
  * @param boolean $crop This argument is deprecated as of Neos 1.2 and will be removed. Don't rely on this behavior and crop labels in the view.
  * @return string
  */
 public function getLabel(NodeInterface $node, $crop = true)
 {
     $label = Utility::evaluateEelExpression($this->getExpression(), $this->eelEvaluator, array('node' => $node), $this->defaultContextConfiguration);
     if ($crop === false) {
         return $label;
     }
     $croppedLabel = Functions::substr($label, 0, 30);
     return $croppedLabel . (strlen($croppedLabel) < strlen($label) ? ' …' : '');
 }
 /**
  * Record events for entity changes.
  *
  * Note: this method is registered as an Doctrine event listener in the settings of this package.
  *
  * TODO: Update/Delete of Entities
  *
  * @param OnFlushEventArgs $eventArgs
  * @return void
  * @throws Exception
  */
 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     if (!$this->eventEmittingService->isEnabled()) {
         return;
     }
     $entityManager = $eventArgs->getEntityManager();
     $unitOfWork = $entityManager->getUnitOfWork();
     foreach ($unitOfWork->getScheduledEntityInsertions() as $entity) {
         $className = get_class($entity);
         if (isset($this->monitorEntitiesSetting[$className])) {
             $entityMonitoringConfiguration = $this->monitorEntitiesSetting[$className];
             if (isset($entityMonitoringConfiguration['events']['created'])) {
                 $this->initializeAccountIdentifier();
                 $data = array();
                 foreach ($entityMonitoringConfiguration['data'] as $key => $eelExpression) {
                     $data[$key] = Utility::evaluateEelExpression($eelExpression, $this->eelEvaluator, array('entity' => $entity));
                 }
                 $event = $this->eventEmittingService->emit($entityMonitoringConfiguration['events']['created'], $data);
                 $unitOfWork->computeChangeSet($entityManager->getClassMetadata(Event::class), $event);
             }
         }
     }
     foreach ($unitOfWork->getScheduledEntityDeletions() as $entity) {
         $className = get_class($entity);
         if (isset($this->monitorEntitiesSetting[$className])) {
             $entityMonitoringConfiguration = $this->monitorEntitiesSetting[$className];
             if (isset($entityMonitoringConfiguration['events']['deleted'])) {
                 $this->initializeAccountIdentifier();
                 $data = array();
                 foreach ($entityMonitoringConfiguration['data'] as $key => $eelExpression) {
                     $data[$key] = Utility::evaluateEelExpression($eelExpression, $this->eelEvaluator, array('entity' => $entity));
                 }
                 $event = $this->eventEmittingService->emit($entityMonitoringConfiguration['events']['deleted'], $data);
                 $unitOfWork->computeChangeSet($entityManager->getClassMetadata(Event::class), $event);
             }
         }
     }
 }
 /**
  * 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);
 }