TYPO3 CMS  TYPO3_6-2
AbstractNode.php
Go to the documentation of this file.
1 <?php
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  $output = NULL;
35  foreach ($this->childNodes as $subNode) {
36  if ($output === NULL) {
37  $output = $subNode->evaluate($renderingContext);
38  } else {
39  if (is_object($output)) {
40  if (!method_exists($output, '__toString')) {
41  throw new \TYPO3\CMS\Fluid\Core\Parser\Exception('Cannot cast object of type "' . get_class($output) . '" to string.', 1248356140);
42  }
43  $output = $output->__toString();
44  } else {
45  $output = (string) $output;
46  }
47  $subNodeOutput = $subNode->evaluate($renderingContext);
48 
49  if (is_object($subNodeOutput)) {
50  if (!method_exists($subNodeOutput, '__toString')) {
51  throw new \TYPO3\CMS\Fluid\Core\Parser\Exception('Cannot cast object of type "' . get_class($subNodeOutput) . '" to string.', 1273753083);
52  }
53  $output .= $subNodeOutput->__toString();
54  } else {
55  $output .= (string) $subNodeOutput;
56  }
57  }
58  }
59  return $output;
60  }
61 
68  public function getChildNodes() {
69  return $this->childNodes;
70  }
71 
78  public function addChildNode(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface $childNode) {
79  $this->childNodes[] = $childNode;
80  }
81 }
addChildNode(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface $childNode)
evaluateChildNodes(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)