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 | * @param NodeInterface[] $childNodes |
||
27 | * @return NodeInterface |
||
28 | */ |
||
29 | public function setChildNodes(array $childNodes) |
||
34 | |||
35 | /** |
||
36 | * Evaluate all child nodes and return the evaluated results. |
||
37 | * |
||
38 | * @param RenderingContextInterface $renderingContext |
||
39 | * @return mixed Normally, an object is returned - in case it is concatenated with a string, a string is returned. |
||
40 | * @throws Parser\Exception |
||
41 | */ |
||
42 | public function evaluateChildNodes(RenderingContextInterface $renderingContext) |
||
57 | |||
58 | /** |
||
59 | * @param NodeInterface $node |
||
60 | * @param RenderingContextInterface $renderingContext |
||
61 | * @param boolean $cast |
||
62 | * @return mixed |
||
63 | */ |
||
64 | protected function evaluateChildNode(NodeInterface $node, RenderingContextInterface $renderingContext, $cast) |
||
72 | |||
73 | /** |
||
74 | * @param mixed $value |
||
75 | * @return string |
||
76 | */ |
||
77 | protected function castToString($value) |
||
85 | |||
86 | /** |
||
87 | * Returns one of the following: |
||
88 | * |
||
89 | * - Itself, if there is more than one child node and one or more nodes are not TextNode or NumericNode |
||
90 | * - A plain value if there is a single child node of type TextNode or NumericNode |
||
91 | * - The one child node if there is only a single child node not of type TextNode or NumericNode |
||
92 | * - Null if there are no child nodes at all. |
||
93 | * |
||
94 | * @param bool $extractNode If TRUE, will extract the value of a single node if the node type contains a scalar value |
||
95 | * @return NodeInterface|string|int|float|null |
||
96 | */ |
||
97 | public function flatten(bool $extractNode = false) |
||
114 | |||
115 | /** |
||
116 | * Returns all child nodes for a given node. |
||
117 | * This is especially needed to implement the boolean expression language. |
||
118 | * |
||
119 | * @return NodeInterface[] A list of nodes |
||
120 | */ |
||
121 | public function getChildNodes() |
||
125 | |||
126 | /** |
||
127 | * Appends a sub node to this node. Is used inside the parser to append children |
||
128 | * |
||
129 | * @param NodeInterface $childNode The sub node to add |
||
130 | * @return self |
||
131 | */ |
||
132 | public function addChildNode(NodeInterface $childNode) |
||
146 | } |
||
147 |