# Source for file Interface.php

Documentation is available at Interface.php

1. <?php
2. /*
3. * $Id: Interface.php 1080 2007-02-10 18:17:08Z romanb $
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, see
19. * <http://www.phpdoctrine.com>.
20. */
21. /**
22. * Doctrine_Node_Interface
23. *
24. * @package Doctrine
25. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
26. * @category Object Relational Mapping
27. * @link www.phpdoctrine.com
28. * @since 1.0
29. * @version $Revision: 1080 $
30. * @author Joe Simms <joe.simms@websites4.com>
31. */
32. interface Doctrine_Node_Interface {
34. /**
35. * test if node has previous sibling
36. *
37. * @return bool
38. */
39. public function hasPrevSibling();
41. /**
42. * test if node has next sibling
43. *
44. * @return bool
45. */
46. public function hasNextSibling();
48. /**
49. * test if node has children
50. *
51. * @return bool
52. */
53. public function hasChildren();
55. /**
56. * test if node has parent
57. *
58. * @return bool
59. */
60. public function hasParent();
62. /**
63. * gets record of prev sibling or empty record
64. *
65. * @return object Doctrine_Record
66. */
67. public function getPrevSibling();
69. /**
70. * gets record of next sibling or empty record
71. *
72. * @return object Doctrine_Record
73. */
74. public function getNextSibling();
76. /**
77. * gets siblings for node
78. *
79. * @return array array of sibling Doctrine_Record objects
80. */
81. public function getSiblings($includeNode = false);
83. /**
84. * gets record of first child or empty record
85. *
86. * @return object Doctrine_Record
87. */
88. public function getFirstChild();
90. /**
91. * gets record of last child or empty record
92. *
93. * @return object Doctrine_Record
94. */
95. public function getLastChild();
97. /**
98. * gets children for node (direct descendants only)
99. *
100. * @return array array of sibling Doctrine_Record objects
101. */
102. public function getChildren();
104. /**
105. * gets descendants for node (direct descendants only)
106. *
107. * @return iterator iterator to traverse descendants from node
108. */
109. public function getDescendants();
111. /**
112. * gets record of parent or empty record
113. *
114. * @return object Doctrine_Record
115. */
116. public function getParent();
118. /**
119. * gets ancestors for node
120. *
121. * @return object Doctrine_Collection
122. */
123. public function getAncestors();
125. /**
126. * gets path to node from root, uses record::toString() method to get node names
127. *
128. * @param string $seperator path seperator
129. * @param bool $includeNode whether or not to include node at end of path
130. * @return string string representation of path
131. */
132. public function getPath($seperator = ' > ', $includeNode = false);
134. /**
135. * gets level (depth) of node in the tree
136. *
137. * @return int
138. */
139. public function getLevel();
141. /**
142. * gets number of children (direct descendants)
143. *
144. * @return int
145. */
146. public function getNumberChildren();
148. /**
149. * gets number of descendants (children and their children)
150. *
151. * @return int
152. */
153. public function getNumberDescendants();
155. /**
156. * inserts node as parent of dest record
157. *
158. * @return bool
159. */
160. public function insertAsParentOf(Doctrine_Record $dest);
162. /**
163. * inserts node as previous sibling of dest record
164. *
165. * @return bool
166. */
167. public function insertAsPrevSiblingOf(Doctrine_Record $dest);
169. /**
170. * inserts node as next sibling of dest record
171. *
172. * @return bool
173. */
174. public function insertAsNextSiblingOf(Doctrine_Record $dest);
176. /**
177. * inserts node as first child of dest record
178. *
179. * @return bool
180. */
181. public function insertAsFirstChildOf(Doctrine_Record $dest);
183. /**
184. * inserts node as first child of dest record
185. *
186. * @return bool
187. */
188. public function insertAsLastChildOf(Doctrine_Record $dest);
190. /**
191. * moves node as prev sibling of dest record
192. *
193. */
194. public function moveAsPrevSiblingOf(Doctrine_Record $dest);
196. /**
197. * moves node as next sibling of dest record
198. *
199. */
200. public function moveAsNextSiblingOf(Doctrine_Record $dest);
202. /**
203. * moves node as first child of dest record
204. *
205. */
206. public function moveAsFirstChildOf(Doctrine_Record $dest);
208. /**
209. * moves node as last child of dest record
210. *
211. */
212. public function moveAsLastChildOf(Doctrine_Record $dest);
214. /**
215. * adds node as last child of record
216. *
217. */
218. public function addChild(Doctrine_Record $record);
220. /**
221. * determines if node is leaf
222. *
223. * @return bool
224. */
225. public function isLeaf();
227. /**
228. * determines if node is root
229. *
230. * @return bool
231. */
232. public function isRoot();
234. /**
235. * determines if node is equal to subject node
236. *
237. * @return bool
238. */
239. public function isEqualTo(Doctrine_Record $subj);
241. /**
242. * determines if node is child of subject node
243. *
244. * @return bool
245. */
246. public function isDescendantOf(Doctrine_Record $subj);
248. /**
249. * determines if node is child of or sibling to subject node
250. *
251. * @return bool
252. */
253. public function isDescendantOfOrEqualTo(Doctrine_Record $subj);
255. /**
256. * determines if node is valid
257. *
258. * @return bool
259. */
260. public function isValidNode();
262. /**
263. * deletes node and it's descendants
264. *
265. */
266. public function delete();
267. }