/**
  * @param \TYPO3\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
  * @return boolean the boolean value
  */
 public function evaluate(\TYPO3\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 {
     if ($this->comparator !== NULL) {
         return self::evaluateComparator($this->comparator, $this->leftSide->evaluate($renderingContext), $this->rightSide->evaluate($renderingContext));
     } else {
         $value = $this->syntaxTreeNode->evaluate($renderingContext);
         return self::convertToBoolean($value);
     }
 }
 /**
  * Returns the name of the layout that is defined within the current template via <f:layout name="..." />
  * If no layout is defined, this returns NULL
  * This requires the current rendering context in order to be able to evaluate the layout name
  *
  * @param RenderingContextInterface $renderingContext
  * @return string
  * @throws View\Exception
  */
 public function getLayoutName(RenderingContextInterface $renderingContext)
 {
     if (!$this->hasLayout()) {
         return null;
     }
     $layoutName = $this->layoutNameNode->evaluate($renderingContext);
     if (!empty($layoutName)) {
         return $layoutName;
     }
     throw new View\Exception('The layoutName could not be evaluated to a string', 1296805368);
 }
 /**
  * The compiled ViewHelper adds two new ViewHelper arguments: __thenClosure and __elseClosure.
  * These contain closures which are be executed to render the then(), respectively else() case.
  *
  * @param string $argumentsVariableName
  * @param string $renderChildrenClosureVariableName
  * @param string $initializationPhpCode
  * @param AbstractNode $syntaxTreeNode
  * @param TemplateCompiler $templateCompiler
  * @return string
  * @Flow\Internal
  */
 public function compile($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, AbstractNode $syntaxTreeNode, TemplateCompiler $templateCompiler)
 {
     foreach ($syntaxTreeNode->getChildNodes() as $childNode) {
         if ($childNode instanceof ViewHelperNode && $childNode->getViewHelperClassName() === \TYPO3\Fluid\ViewHelpers\ThenViewHelper::class) {
             $childNodesAsClosure = $templateCompiler->wrapChildNodesInClosure($childNode);
             $initializationPhpCode .= sprintf('%s[\'__thenClosure\'] = %s;', $argumentsVariableName, $childNodesAsClosure) . chr(10);
         }
         if ($childNode instanceof ViewHelperNode && $childNode->getViewHelperClassName() === \TYPO3\Fluid\ViewHelpers\ElseViewHelper::class) {
             $childNodesAsClosure = $templateCompiler->wrapChildNodesInClosure($childNode);
             $initializationPhpCode .= sprintf('%s[\'__elseClosure\'] = %s;', $argumentsVariableName, $childNodesAsClosure) . chr(10);
         }
     }
     return TemplateCompiler::SHOULD_GENERATE_VIEWHELPER_INVOCATION;
 }
Exemplo n.º 4
0
 /**
  * @param AbstractNode $node
  * @return array
  * @see convert()
  */
 public function convertListOfSubNodes(AbstractNode $node)
 {
     switch (count($node->getChildNodes())) {
         case 0:
             return array('initialization' => '', 'execution' => 'NULL');
         case 1:
             $converted = $this->convert(current($node->getChildNodes()));
             return $converted;
         default:
             $outputVariableName = $this->variableName('output');
             $initializationPhpCode = sprintf('%s = \'\';', $outputVariableName) . chr(10);
             foreach ($node->getChildNodes() as $childNode) {
                 $converted = $this->convert($childNode);
                 $initializationPhpCode .= $converted['initialization'] . chr(10);
                 $initializationPhpCode .= sprintf('%s .= %s;', $outputVariableName, $converted['execution']) . chr(10);
             }
             return array('initialization' => $initializationPhpCode, 'execution' => $outputVariableName);
     }
 }