TYPO3  7.6
fluid/Classes/Core/Parser/SyntaxTree/AbstractNode.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Fluid\Core\Parser\SyntaxTree;
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
18 {
24  protected $childNodes = array();
25 
33  public function evaluateChildNodes(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
34  {
35  $output = null;
36  foreach ($this->childNodes as $subNode) {
37  if ($output === null) {
38  $output = $subNode->evaluate($renderingContext);
39  } else {
40  if (is_object($output)) {
41  if (!method_exists($output, '__toString')) {
42  throw new \TYPO3\CMS\Fluid\Core\Parser\Exception('Cannot cast object of type "' . get_class($output) . '" to string.', 1248356140);
43  }
44  $output = $output->__toString();
45  } else {
46  $output = (string)$output;
47  }
48  $subNodeOutput = $subNode->evaluate($renderingContext);
49 
50  if (is_object($subNodeOutput)) {
51  if (!method_exists($subNodeOutput, '__toString')) {
52  throw new \TYPO3\CMS\Fluid\Core\Parser\Exception('Cannot cast object of type "' . get_class($subNodeOutput) . '" to string.', 1273753083);
53  }
54  $output .= $subNodeOutput->__toString();
55  } else {
56  $output .= (string)$subNodeOutput;
57  }
58  }
59  }
60  return $output;
61  }
62 
69  public function getChildNodes()
70  {
71  return $this->childNodes;
72  }
73 
80  public function addChildNode(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface $childNode)
81  {
82  $this->childNodes[] = $childNode;
83  }
84 }