1 | <?php |
||
15 | abstract class AbstractNode implements NodeInterface |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * List of Child Nodes. |
||
20 | * |
||
21 | * @var NodeInterface[] |
||
22 | */ |
||
23 | protected $childNodes = []; |
||
24 | |||
25 | /** |
||
26 | * Evaluate all child nodes and return the evaluated results. |
||
27 | * |
||
28 | * @param RenderingContextInterface $renderingContext |
||
29 | * @return mixed Normally, an object is returned - in case it is concatenated with a string, a string is returned. |
||
30 | * @throws Parser\Exception |
||
31 | */ |
||
32 | public function evaluateChildNodes(RenderingContextInterface $renderingContext) |
||
47 | |||
48 | /** |
||
49 | * @param NodeInterface $node |
||
50 | * @param RenderingContextInterface $renderingContext |
||
51 | * @param boolean $cast |
||
52 | * @return mixed |
||
53 | */ |
||
54 | protected function evaluateChildNode(NodeInterface $node, RenderingContextInterface $renderingContext, $cast) |
||
62 | |||
63 | /** |
||
64 | * @param mixed $value |
||
65 | * @return string |
||
66 | */ |
||
67 | protected function castToString($value) |
||
68 | { |
||
69 | if (is_object($value) && !method_exists($value, '__toString')) { |
||
70 | throw new Parser\Exception('Cannot cast object of type "' . get_class($value) . '" to string.', 1273753083); |
||
71 | } |
||
72 | $output = (string) $value; |
||
73 | return $output; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Returns all child nodes for a given node. |
||
78 | * This is especially needed to implement the boolean expression language. |
||
79 | * |
||
80 | * @return NodeInterface[] A list of nodes |
||
81 | */ |
||
82 | public function getChildNodes() |
||
86 | |||
87 | /** |
||
88 | * Appends a sub node to this node. Is used inside the parser to append children |
||
89 | * |
||
90 | * @param NodeInterface $childNode The sub node to add |
||
91 | * @return void |
||
92 | */ |
||
93 | public function addChildNode(NodeInterface $childNode) |
||
97 | } |
||
98 |