1 | <?php |
---|
2 | /* |
---|
3 | * $Id: NodePeer.php 797 2007-11-09 19:21:21Z heltem $ |
---|
4 | * |
---|
5 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
6 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
7 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
8 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
9 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
10 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
11 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
12 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
13 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
14 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
15 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
16 | * |
---|
17 | * This software consists of voluntary contributions made by many individuals |
---|
18 | * and is licensed under the LGPL. For more information please see |
---|
19 | * <http://propel.phpdb.org>. |
---|
20 | */ |
---|
21 | |
---|
22 | /** |
---|
23 | * This is a utility interface for all generated NodePeer classes in the system. |
---|
24 | * |
---|
25 | * @author Heltem <heltem@o2php.com> (Propel) |
---|
26 | * @version $Revision: 797 $ |
---|
27 | * @package propel.util |
---|
28 | */ |
---|
29 | interface NodePeer { |
---|
30 | /** |
---|
31 | * Creates the supplied node as the root node. |
---|
32 | * |
---|
33 | * @param object $node Propel object for model |
---|
34 | * @return object Inserted propel object for model |
---|
35 | */ |
---|
36 | public static function createRoot(NodeObject $node); |
---|
37 | |
---|
38 | /** |
---|
39 | * Returns the root node for a given scope id |
---|
40 | * |
---|
41 | * @param int $scopeId Scope id to determine which root node to return |
---|
42 | * @param PropelPDO $con Connection to use. |
---|
43 | * @return object Propel object for root node |
---|
44 | */ |
---|
45 | public static function retrieveRoot($scopeId = 1, PropelPDO $con = null); |
---|
46 | |
---|
47 | /** |
---|
48 | * Inserts $child as first child of destination node $parent |
---|
49 | * |
---|
50 | * @param object $child Propel object for child node |
---|
51 | * @param object $parent Propel object for parent node |
---|
52 | * @param PropelPDO $con Connection to use. |
---|
53 | * @return void |
---|
54 | */ |
---|
55 | public static function insertAsFirstChildOf(NodeObject $child, NodeObject $parent, PropelPDO $con = null); |
---|
56 | |
---|
57 | /** |
---|
58 | * Inserts $child as last child of destination node $parent |
---|
59 | * |
---|
60 | * @param object $child Propel object for child node |
---|
61 | * @param object $parent Propel object for parent node |
---|
62 | * @param PropelPDO $con Connection to use. |
---|
63 | * @return void |
---|
64 | */ |
---|
65 | public static function insertAsLastChildOf(NodeObject $child, NodeObject $parent, PropelPDO $con = null); |
---|
66 | |
---|
67 | /** |
---|
68 | * Inserts $sibling as previous sibling to destination node $node |
---|
69 | * |
---|
70 | * @param object $node Propel object for destination node |
---|
71 | * @param object $sibling Propel object for source node |
---|
72 | * @param PropelPDO $con Connection to use. |
---|
73 | * @return void |
---|
74 | */ |
---|
75 | public static function insertAsPrevSiblingOf(NodeObject $node, NodeObject $sibling, PropelPDO $con = null); |
---|
76 | |
---|
77 | /** |
---|
78 | * Inserts $sibling as next sibling to destination node $node |
---|
79 | * |
---|
80 | * @param object $node Propel object for destination node |
---|
81 | * @param object $sibling Propel object for source node |
---|
82 | * @param PropelPDO $con Connection to use. |
---|
83 | * @return void |
---|
84 | */ |
---|
85 | public static function insertAsNextSiblingOf(NodeObject $node, NodeObject $sibling, PropelPDO $con = null); |
---|
86 | |
---|
87 | /** |
---|
88 | * Inserts $parent as parent of given $node. |
---|
89 | * |
---|
90 | * @param object $parent Propel object for given parent node |
---|
91 | * @param object $node Propel object for given destination node |
---|
92 | * @param PropelPDO $con Connection to use. |
---|
93 | * @return void |
---|
94 | * @throws Exception When trying to insert node as parent of a root node |
---|
95 | */ |
---|
96 | public static function insertAsParentOf(NodeObject $parent, NodeObject $node, PropelPDO $con = null); |
---|
97 | |
---|
98 | /** |
---|
99 | * Inserts $node as root node |
---|
100 | * |
---|
101 | * @param object $node Propel object as root node |
---|
102 | * @param PropelPDO $con Connection to use. |
---|
103 | * @return void |
---|
104 | */ |
---|
105 | public static function insertRoot(NodeObject $node, PropelPDO $con = null); |
---|
106 | |
---|
107 | /** |
---|
108 | * Delete root node |
---|
109 | * |
---|
110 | * @param int $scopeId Scope id to determine which root node to delete |
---|
111 | * @param PropelPDO $con Connection to use. |
---|
112 | * @return boolean Deletion status |
---|
113 | */ |
---|
114 | public static function deleteRoot($scopeId = 1, PropelPDO $con = null); |
---|
115 | |
---|
116 | /** |
---|
117 | * Delete $dest node |
---|
118 | * |
---|
119 | * @param object $dest Propel object node to delete |
---|
120 | * @param PropelPDO $con Connection to use. |
---|
121 | * @return boolean Deletion status |
---|
122 | */ |
---|
123 | public static function deleteNode(NodeObject $dest, PropelPDO $con = null); |
---|
124 | |
---|
125 | /** |
---|
126 | * Moves $child to be first child of $parent |
---|
127 | * |
---|
128 | * @param object $parent Propel object for parent node |
---|
129 | * @param object $child Propel object for child node |
---|
130 | * @param PropelPDO $con Connection to use. |
---|
131 | * @return void |
---|
132 | */ |
---|
133 | public static function moveToFirstChildOf(NodeObject $parent, NodeObject $child, PropelPDO $con = null); |
---|
134 | |
---|
135 | /** |
---|
136 | * Moves $node to be last child of $dest |
---|
137 | * |
---|
138 | * @param object $dest Propel object for destination node |
---|
139 | * @param object $node Propel object for source node |
---|
140 | * @param PropelPDO $con Connection to use. |
---|
141 | * @return void |
---|
142 | */ |
---|
143 | public static function moveToLastChildOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); |
---|
144 | |
---|
145 | /** |
---|
146 | * Moves $node to be prev sibling to $dest |
---|
147 | * |
---|
148 | * @param object $dest Propel object for destination node |
---|
149 | * @param object $node Propel object for source node |
---|
150 | * @param PropelPDO $con Connection to use. |
---|
151 | * @return void |
---|
152 | */ |
---|
153 | public static function moveToPrevSiblingOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); |
---|
154 | |
---|
155 | /** |
---|
156 | * Moves $node to be next sibling to $dest |
---|
157 | * |
---|
158 | * @param object $dest Propel object for destination node |
---|
159 | * @param object $node Propel object for source node |
---|
160 | * @param PropelPDO $con Connection to use. |
---|
161 | * @return void |
---|
162 | */ |
---|
163 | public static function moveToNextSiblingOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null); |
---|
164 | |
---|
165 | /** |
---|
166 | * Gets first child for the given node if it exists |
---|
167 | * |
---|
168 | * @param object $node Propel object for src node |
---|
169 | * @param PropelPDO $con Connection to use. |
---|
170 | * @return mixed Propel object if exists else false |
---|
171 | */ |
---|
172 | public static function retrieveFirstChild(NodeObject $node, PropelPDO $con = null); |
---|
173 | |
---|
174 | /** |
---|
175 | * Gets last child for the given node if it exists |
---|
176 | * |
---|
177 | * @param object $node Propel object for src node |
---|
178 | * @param PropelPDO $con Connection to use. |
---|
179 | * @return mixed Propel object if exists else false |
---|
180 | */ |
---|
181 | public static function retrieveLastChild(NodeObject $node, PropelPDO $con = null); |
---|
182 | |
---|
183 | /** |
---|
184 | * Gets prev sibling for the given node if it exists |
---|
185 | * |
---|
186 | * @param object $node Propel object for src node |
---|
187 | * @param PropelPDO $con Connection to use. |
---|
188 | * @return mixed Propel object if exists else false |
---|
189 | */ |
---|
190 | public static function retrievePrevSibling(NodeObject $node, PropelPDO $con = null); |
---|
191 | |
---|
192 | /** |
---|
193 | * Gets next sibling for the given node if it exists |
---|
194 | * |
---|
195 | * @param object $node Propel object for src node |
---|
196 | * @param PropelPDO $con Connection to use. |
---|
197 | * @return mixed Propel object if exists else false |
---|
198 | */ |
---|
199 | public static function retrieveNextSibling(NodeObject $node, PropelPDO $con = null); |
---|
200 | |
---|
201 | /** |
---|
202 | * Retrieves the entire tree from root |
---|
203 | * |
---|
204 | * @param int $scopeId Scope id to determine which scope tree to return |
---|
205 | * @param PropelPDO $con Connection to use. |
---|
206 | */ |
---|
207 | public static function retrieveTree($scopeId = 1, PropelPDO $con = null); |
---|
208 | |
---|
209 | /** |
---|
210 | * Retrieves the entire tree from parent $node |
---|
211 | * |
---|
212 | * @param PropelPDO $con Connection to use. |
---|
213 | */ |
---|
214 | public static function retrieveBranch(NodeObject $node, PropelPDO $con = null); |
---|
215 | |
---|
216 | /** |
---|
217 | * Gets direct children for the node |
---|
218 | * |
---|
219 | * @param object $node Propel object for parent node |
---|
220 | * @param PropelPDO $con Connection to use. |
---|
221 | */ |
---|
222 | public static function retrieveChildren(NodeObject $node, PropelPDO $con = null); |
---|
223 | |
---|
224 | /** |
---|
225 | * Gets all descendants for the node |
---|
226 | * |
---|
227 | * @param object $node Propel object for parent node |
---|
228 | * @param PropelPDO $con Connection to use. |
---|
229 | */ |
---|
230 | public static function retrieveDescendants(NodeObject $node, PropelPDO $con = null); |
---|
231 | |
---|
232 | /** |
---|
233 | * Gets all siblings for the node |
---|
234 | * |
---|
235 | * @param object $node Propel object for src node |
---|
236 | * @param PropelPDO $con Connection to use. |
---|
237 | */ |
---|
238 | public static function retrieveSiblings(NodeObject $node, PropelPDO $con = null); |
---|
239 | |
---|
240 | /** |
---|
241 | * Gets ancestor for the given node if it exists |
---|
242 | * |
---|
243 | * @param object $node Propel object for src node |
---|
244 | * @param PropelPDO $con Connection to use. |
---|
245 | * @return mixed Propel object if exists else false |
---|
246 | */ |
---|
247 | public static function retrieveParent(NodeObject $node, PropelPDO $con = null); |
---|
248 | |
---|
249 | /** |
---|
250 | * Gets level for the given node |
---|
251 | * |
---|
252 | * @param object $node Propel object for src node |
---|
253 | * @param PropelPDO $con Connection to use. |
---|
254 | * @return int Level for the given node |
---|
255 | */ |
---|
256 | public static function getLevel(NodeObject $node, PropelPDO $con = null); |
---|
257 | |
---|
258 | /** |
---|
259 | * Gets number of direct children for given node |
---|
260 | * |
---|
261 | * @param object $node Propel object for src node |
---|
262 | * @param PropelPDO $con Connection to use. |
---|
263 | * @return int Level for the given node |
---|
264 | */ |
---|
265 | public static function getNumberOfChildren(NodeObject $node, PropelPDO $con = null); |
---|
266 | |
---|
267 | /** |
---|
268 | * Gets number of descendants for given node |
---|
269 | * |
---|
270 | * @param object $node Propel object for src node |
---|
271 | * @param PropelPDO $con Connection to use. |
---|
272 | * @return int Level for the given node |
---|
273 | */ |
---|
274 | public static function getNumberOfDescendants(NodeObject $node, PropelPDO $con = null); |
---|
275 | |
---|
276 | /** |
---|
277 | * Returns path to a specific node as an array, useful to create breadcrumbs |
---|
278 | * |
---|
279 | * @param object $node Propel object of node to create path to |
---|
280 | * @param PropelPDO $con Connection to use. |
---|
281 | * @return array Array in order of heirarchy |
---|
282 | */ |
---|
283 | public static function getPath(NodeObject $node, PropelPDO $con = null); |
---|
284 | |
---|
285 | /** |
---|
286 | * Tests if node is valid |
---|
287 | * |
---|
288 | * @param object $node Propel object for src node |
---|
289 | * @return bool |
---|
290 | */ |
---|
291 | public static function isValid(NodeObject $node = null); |
---|
292 | |
---|
293 | /** |
---|
294 | * Tests if node is a root |
---|
295 | * |
---|
296 | * @param object $node Propel object for src node |
---|
297 | * @return bool |
---|
298 | */ |
---|
299 | public static function isRoot(NodeObject $node); |
---|
300 | |
---|
301 | /** |
---|
302 | * Tests if node is a leaf |
---|
303 | * |
---|
304 | * @param object $node Propel object for src node |
---|
305 | * @return bool |
---|
306 | */ |
---|
307 | public static function isLeaf(NodeObject $node); |
---|
308 | |
---|
309 | /** |
---|
310 | * Tests if $child is a child of $parent |
---|
311 | * |
---|
312 | * @param object $child Propel object for node |
---|
313 | * @param object $parent Propel object for node |
---|
314 | * @return bool |
---|
315 | */ |
---|
316 | public static function isChildOf(NodeObject $child, NodeObject $parent); |
---|
317 | |
---|
318 | /** |
---|
319 | * Tests if $node1 is equal to $node2 |
---|
320 | * |
---|
321 | * @param object $node1 Propel object for node |
---|
322 | * @param object $node2 Propel object for node |
---|
323 | * @return bool |
---|
324 | */ |
---|
325 | public static function isEqualTo(NodeObject $node1, NodeObject $node2); |
---|
326 | |
---|
327 | /** |
---|
328 | * Tests if $node has an ancestor |
---|
329 | * |
---|
330 | * @param object $node Propel object for node |
---|
331 | * @param PropelPDO $con Connection to use. |
---|
332 | * @return bool |
---|
333 | */ |
---|
334 | public static function hasParent(NodeObject $node, PropelPDO $con = null); |
---|
335 | |
---|
336 | /** |
---|
337 | * Tests if $node has prev sibling |
---|
338 | * |
---|
339 | * @param object $node Propel object for node |
---|
340 | * @param PropelPDO $con Connection to use. |
---|
341 | * @return bool |
---|
342 | */ |
---|
343 | public static function hasPrevSibling(NodeObject $node, PropelPDO $con = null); |
---|
344 | |
---|
345 | /** |
---|
346 | * Tests if $node has next sibling |
---|
347 | * |
---|
348 | * @param object $node Propel object for node |
---|
349 | * @param PropelPDO $con Connection to use. |
---|
350 | * @return bool |
---|
351 | */ |
---|
352 | public static function hasNextSibling(NodeObject $node, PropelPDO $con = null); |
---|
353 | |
---|
354 | /** |
---|
355 | * Tests if $node has children |
---|
356 | * |
---|
357 | * @param object $node Propel object for node |
---|
358 | * @return bool |
---|
359 | */ |
---|
360 | public static function hasChildren(NodeObject $node); |
---|
361 | |
---|
362 | /** |
---|
363 | * Deletes $node and all of its descendants |
---|
364 | * |
---|
365 | * @param object $node Propel object for source node |
---|
366 | * @param PropelPDO $con Connection to use. |
---|
367 | */ |
---|
368 | public static function deleteDescendants(NodeObject $node, PropelPDO $con = null); |
---|
369 | |
---|
370 | /** |
---|
371 | * Returns a node given its primary key or the node itself |
---|
372 | * |
---|
373 | * @param int/object $node Primary key/instance of required node |
---|
374 | * @param PropelPDO $con Connection to use. |
---|
375 | * @return object Propel object for model |
---|
376 | */ |
---|
377 | public static function getNode($node, PropelPDO $con = null); |
---|
378 | |
---|
379 | } // NodePeer |
---|