1 | <?php |
||
23 | abstract class AbstractNode implements AlphabeticalTreeNodeInterface { |
||
24 | |||
25 | /** |
||
26 | * Id. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | private $id; |
||
31 | |||
32 | /** |
||
33 | * Index. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | private $index; |
||
38 | |||
39 | /** |
||
40 | * Children nodes. |
||
41 | * |
||
42 | * @var AbstractNode[] |
||
43 | */ |
||
44 | private $nodes; |
||
45 | |||
46 | /** |
||
47 | * Parent node. |
||
48 | * |
||
49 | * @var AbstractNode |
||
50 | */ |
||
51 | private $parent; |
||
52 | |||
53 | /** |
||
54 | * Constructor. |
||
55 | * |
||
56 | * @param string $id The id. |
||
57 | */ |
||
58 | protected function __construct($id) { |
||
64 | |||
65 | /** |
||
66 | * Add a children node. |
||
67 | * |
||
68 | * @param AbstractNode $node The children node. |
||
69 | * @return AbstractNode Returns this node. |
||
70 | */ |
||
71 | public function addNode(AbstractNode $node) { |
||
77 | |||
78 | /** |
||
79 | * Clear the nodes. |
||
80 | * |
||
81 | * @return AbstractNode Returns this node. |
||
82 | */ |
||
83 | public function clearNodes() { |
||
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | public function getAlphabeticalTreeNodeLabel() { |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | public function getAlphabeticalTreeNodeParent() { |
||
103 | |||
104 | /** |
||
105 | * Get the first children node. |
||
106 | * |
||
107 | * @return AbstractNode|null Returns the first node in case of success, null otherwise. |
||
108 | */ |
||
109 | public function getFirstNode() { |
||
112 | |||
113 | /** |
||
114 | * Get the id. |
||
115 | * |
||
116 | * @return string Returns the id. |
||
117 | */ |
||
118 | public function getId() { |
||
121 | |||
122 | /** |
||
123 | * Get the last children node. |
||
124 | * |
||
125 | * @return AbstractNode|null Returns the last node in case of success, null otherwise. |
||
126 | */ |
||
127 | public function getLastNode() { |
||
130 | |||
131 | /** |
||
132 | * Get a node at position. |
||
133 | * |
||
134 | * @param int $position The position. |
||
135 | * @return AbstractNode|null Returns the node in case of success, null otherwise. |
||
136 | */ |
||
137 | public function getNodeAt($position) { |
||
143 | |||
144 | /** |
||
145 | * Get a node by id. |
||
146 | * |
||
147 | * @param string $id The id. |
||
148 | * @param bool $recursively Recursively ? |
||
149 | * @return AbstractNode|null Returns a node in case of success, null otherwise. |
||
150 | */ |
||
151 | public function getNodeById($id, $recursively = false) { |
||
166 | |||
167 | /** |
||
168 | * Get the nodes. |
||
169 | * |
||
170 | * @return AbstractNode[] Returns the nodes. |
||
171 | */ |
||
172 | public function getNodes() { |
||
175 | |||
176 | /** |
||
177 | * Get the parent. |
||
178 | * |
||
179 | * @return AbstractNode Returns the parent. |
||
180 | */ |
||
181 | public function getParent() { |
||
184 | |||
185 | /** |
||
186 | * Remove a node. |
||
187 | * |
||
188 | * @param AbstractNode $node The children node. |
||
189 | * @return AbstractNode Returns this node. |
||
190 | */ |
||
191 | public function removeNode(AbstractNode $node) { |
||
199 | |||
200 | /** |
||
201 | * Set the id. |
||
202 | * |
||
203 | * @param string $id The id. |
||
204 | * @return AbstractNode Returns this node. |
||
205 | */ |
||
206 | protected function setId($id) { |
||
210 | |||
211 | /** |
||
212 | * Set the index. |
||
213 | * |
||
214 | * @param array $index The index. |
||
215 | * @return AbstractNode Returns this node. |
||
216 | */ |
||
217 | protected function setIndex(array $index) { |
||
221 | |||
222 | /** |
||
223 | * Set the nodes. |
||
224 | * |
||
225 | * @param AbstractNode[] $nodes The nodes. |
||
226 | * @return AbstractNode Returns this node. |
||
227 | */ |
||
228 | protected function setNodes(array $nodes) { |
||
232 | |||
233 | /** |
||
234 | * Set the parent. |
||
235 | * |
||
236 | * @param AbstractNode $parent The parent. |
||
237 | * @return AbstractNode Returns this node. |
||
238 | */ |
||
239 | protected function setParent(AbstractNode $parent = null) { |
||
243 | |||
244 | /** |
||
245 | * Size. |
||
246 | * |
||
247 | * @return int Returns the size. |
||
248 | */ |
||
249 | public function size() { |
||
252 | } |
||
253 |