NodePeer.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <?php
  2. /**
  3. * This file is part of the Propel package.
  4. * For the full copyright and license information, please view the LICENSE
  5. * file that was distributed with this source code.
  6. *
  7. * @license MIT License
  8. */
  9. /**
  10. * This is a utility interface for all generated NodePeer classes in the system.
  11. *
  12. * @author Heltem <heltem@o2php.com> (Propel)
  13. * @version $Revision: 1612 $
  14. * @package propel.runtime.util
  15. */
  16. interface NodePeer
  17. {
  18. /**
  19. * Creates the supplied node as the root node.
  20. *
  21. * @param object $node Propel object for model
  22. * @return object Inserted propel object for model
  23. */
  24. public static function createRoot(NodeObject $node);
  25. /**
  26. * Returns the root node for a given scope id
  27. *
  28. * @param int $scopeId Scope id to determine which root node to return
  29. * @param PropelPDO $con Connection to use.
  30. * @return object Propel object for root node
  31. */
  32. public static function retrieveRoot($scopeId = 1, PropelPDO $con = null);
  33. /**
  34. * Inserts $child as first child of destination node $parent
  35. *
  36. * @param object $child Propel object for child node
  37. * @param object $parent Propel object for parent node
  38. * @param PropelPDO $con Connection to use.
  39. * @return void
  40. */
  41. public static function insertAsFirstChildOf(NodeObject $child, NodeObject $parent, PropelPDO $con = null);
  42. /**
  43. * Inserts $child as last child of destination node $parent
  44. *
  45. * @param object $child Propel object for child node
  46. * @param object $parent Propel object for parent node
  47. * @param PropelPDO $con Connection to use.
  48. * @return void
  49. */
  50. public static function insertAsLastChildOf(NodeObject $child, NodeObject $parent, PropelPDO $con = null);
  51. /**
  52. * Inserts $sibling as previous sibling to destination node $node
  53. *
  54. * @param object $node Propel object for destination node
  55. * @param object $sibling Propel object for source node
  56. * @param PropelPDO $con Connection to use.
  57. * @return void
  58. */
  59. public static function insertAsPrevSiblingOf(NodeObject $node, NodeObject $sibling, PropelPDO $con = null);
  60. /**
  61. * Inserts $sibling as next sibling to destination node $node
  62. *
  63. * @param object $node Propel object for destination node
  64. * @param object $sibling Propel object for source node
  65. * @param PropelPDO $con Connection to use.
  66. * @return void
  67. */
  68. public static function insertAsNextSiblingOf(NodeObject $node, NodeObject $sibling, PropelPDO $con = null);
  69. /**
  70. * Inserts $parent as parent of given $node.
  71. *
  72. * @param object $parent Propel object for given parent node
  73. * @param object $node Propel object for given destination node
  74. * @param PropelPDO $con Connection to use.
  75. * @return void
  76. * @throws Exception When trying to insert node as parent of a root node
  77. */
  78. public static function insertAsParentOf(NodeObject $parent, NodeObject $node, PropelPDO $con = null);
  79. /**
  80. * Inserts $node as root node
  81. *
  82. * @param object $node Propel object as root node
  83. * @param PropelPDO $con Connection to use.
  84. * @return void
  85. */
  86. public static function insertRoot(NodeObject $node, PropelPDO $con = null);
  87. /**
  88. * Delete root node
  89. *
  90. * @param int $scopeId Scope id to determine which root node to delete
  91. * @param PropelPDO $con Connection to use.
  92. * @return boolean Deletion status
  93. */
  94. public static function deleteRoot($scopeId = 1, PropelPDO $con = null);
  95. /**
  96. * Delete $dest node
  97. *
  98. * @param object $dest Propel object node to delete
  99. * @param PropelPDO $con Connection to use.
  100. * @return boolean Deletion status
  101. */
  102. public static function deleteNode(NodeObject $dest, PropelPDO $con = null);
  103. /**
  104. * Moves $child to be first child of $parent
  105. *
  106. * @param object $parent Propel object for parent node
  107. * @param object $child Propel object for child node
  108. * @param PropelPDO $con Connection to use.
  109. * @return void
  110. */
  111. public static function moveToFirstChildOf(NodeObject $parent, NodeObject $child, PropelPDO $con = null);
  112. /**
  113. * Moves $node to be last child of $dest
  114. *
  115. * @param object $dest Propel object for destination node
  116. * @param object $node Propel object for source node
  117. * @param PropelPDO $con Connection to use.
  118. * @return void
  119. */
  120. public static function moveToLastChildOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null);
  121. /**
  122. * Moves $node to be prev sibling to $dest
  123. *
  124. * @param object $dest Propel object for destination node
  125. * @param object $node Propel object for source node
  126. * @param PropelPDO $con Connection to use.
  127. * @return void
  128. */
  129. public static function moveToPrevSiblingOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null);
  130. /**
  131. * Moves $node to be next sibling to $dest
  132. *
  133. * @param object $dest Propel object for destination node
  134. * @param object $node Propel object for source node
  135. * @param PropelPDO $con Connection to use.
  136. * @return void
  137. */
  138. public static function moveToNextSiblingOf(NodeObject $dest, NodeObject $node, PropelPDO $con = null);
  139. /**
  140. * Gets first child for the given node if it exists
  141. *
  142. * @param object $node Propel object for src node
  143. * @param PropelPDO $con Connection to use.
  144. * @return mixed Propel object if exists else false
  145. */
  146. public static function retrieveFirstChild(NodeObject $node, PropelPDO $con = null);
  147. /**
  148. * Gets last child for the given node if it exists
  149. *
  150. * @param object $node Propel object for src node
  151. * @param PropelPDO $con Connection to use.
  152. * @return mixed Propel object if exists else false
  153. */
  154. public static function retrieveLastChild(NodeObject $node, PropelPDO $con = null);
  155. /**
  156. * Gets prev sibling for the given node if it exists
  157. *
  158. * @param object $node Propel object for src node
  159. * @param PropelPDO $con Connection to use.
  160. * @return mixed Propel object if exists else false
  161. */
  162. public static function retrievePrevSibling(NodeObject $node, PropelPDO $con = null);
  163. /**
  164. * Gets next sibling for the given node if it exists
  165. *
  166. * @param object $node Propel object for src node
  167. * @param PropelPDO $con Connection to use.
  168. * @return mixed Propel object if exists else false
  169. */
  170. public static function retrieveNextSibling(NodeObject $node, PropelPDO $con = null);
  171. /**
  172. * Retrieves the entire tree from root
  173. *
  174. * @param int $scopeId Scope id to determine which scope tree to return
  175. * @param PropelPDO $con Connection to use.
  176. */
  177. public static function retrieveTree($scopeId = 1, PropelPDO $con = null);
  178. /**
  179. * Retrieves the entire tree from parent $node
  180. *
  181. * @param PropelPDO $con Connection to use.
  182. */
  183. public static function retrieveBranch(NodeObject $node, PropelPDO $con = null);
  184. /**
  185. * Gets direct children for the node
  186. *
  187. * @param object $node Propel object for parent node
  188. * @param PropelPDO $con Connection to use.
  189. */
  190. public static function retrieveChildren(NodeObject $node, PropelPDO $con = null);
  191. /**
  192. * Gets all descendants for the node
  193. *
  194. * @param object $node Propel object for parent node
  195. * @param PropelPDO $con Connection to use.
  196. */
  197. public static function retrieveDescendants(NodeObject $node, PropelPDO $con = null);
  198. /**
  199. * Gets all siblings for the node
  200. *
  201. * @param object $node Propel object for src node
  202. * @param PropelPDO $con Connection to use.
  203. */
  204. public static function retrieveSiblings(NodeObject $node, PropelPDO $con = null);
  205. /**
  206. * Gets ancestor for the given node if it exists
  207. *
  208. * @param object $node Propel object for src node
  209. * @param PropelPDO $con Connection to use.
  210. * @return mixed Propel object if exists else false
  211. */
  212. public static function retrieveParent(NodeObject $node, PropelPDO $con = null);
  213. /**
  214. * Gets level for the given node
  215. *
  216. * @param object $node Propel object for src node
  217. * @param PropelPDO $con Connection to use.
  218. * @return int Level for the given node
  219. */
  220. public static function getLevel(NodeObject $node, PropelPDO $con = null);
  221. /**
  222. * Gets number of direct children for given node
  223. *
  224. * @param object $node Propel object for src node
  225. * @param PropelPDO $con Connection to use.
  226. * @return int Level for the given node
  227. */
  228. public static function getNumberOfChildren(NodeObject $node, PropelPDO $con = null);
  229. /**
  230. * Gets number of descendants for given node
  231. *
  232. * @param object $node Propel object for src node
  233. * @param PropelPDO $con Connection to use.
  234. * @return int Level for the given node
  235. */
  236. public static function getNumberOfDescendants(NodeObject $node, PropelPDO $con = null);
  237. /**
  238. * Returns path to a specific node as an array, useful to create breadcrumbs
  239. *
  240. * @param object $node Propel object of node to create path to
  241. * @param PropelPDO $con Connection to use.
  242. * @return array Array in order of heirarchy
  243. */
  244. public static function getPath(NodeObject $node, PropelPDO $con = null);
  245. /**
  246. * Tests if node is valid
  247. *
  248. * @param object $node Propel object for src node
  249. * @return bool
  250. */
  251. public static function isValid(NodeObject $node = null);
  252. /**
  253. * Tests if node is a root
  254. *
  255. * @param object $node Propel object for src node
  256. * @return bool
  257. */
  258. public static function isRoot(NodeObject $node);
  259. /**
  260. * Tests if node is a leaf
  261. *
  262. * @param object $node Propel object for src node
  263. * @return bool
  264. */
  265. public static function isLeaf(NodeObject $node);
  266. /**
  267. * Tests if $child is a child of $parent
  268. *
  269. * @param object $child Propel object for node
  270. * @param object $parent Propel object for node
  271. * @return bool
  272. */
  273. public static function isChildOf(NodeObject $child, NodeObject $parent);
  274. /**
  275. * Tests if $node1 is equal to $node2
  276. *
  277. * @param object $node1 Propel object for node
  278. * @param object $node2 Propel object for node
  279. * @return bool
  280. */
  281. public static function isEqualTo(NodeObject $node1, NodeObject $node2);
  282. /**
  283. * Tests if $node has an ancestor
  284. *
  285. * @param object $node Propel object for node
  286. * @param PropelPDO $con Connection to use.
  287. * @return bool
  288. */
  289. public static function hasParent(NodeObject $node, PropelPDO $con = null);
  290. /**
  291. * Tests if $node has prev sibling
  292. *
  293. * @param object $node Propel object for node
  294. * @param PropelPDO $con Connection to use.
  295. * @return bool
  296. */
  297. public static function hasPrevSibling(NodeObject $node, PropelPDO $con = null);
  298. /**
  299. * Tests if $node has next sibling
  300. *
  301. * @param object $node Propel object for node
  302. * @param PropelPDO $con Connection to use.
  303. * @return bool
  304. */
  305. public static function hasNextSibling(NodeObject $node, PropelPDO $con = null);
  306. /**
  307. * Tests if $node has children
  308. *
  309. * @param object $node Propel object for node
  310. * @return bool
  311. */
  312. public static function hasChildren(NodeObject $node);
  313. /**
  314. * Deletes $node and all of its descendants
  315. *
  316. * @param object $node Propel object for source node
  317. * @param PropelPDO $con Connection to use.
  318. */
  319. public static function deleteDescendants(NodeObject $node, PropelPDO $con = null);
  320. /**
  321. * Returns a node given its primary key or the node itself
  322. *
  323. * @param int/object $node Primary key/instance of required node
  324. * @param PropelPDO $con Connection to use.
  325. * @return object Propel object for model
  326. */
  327. public static function getNode($node, PropelPDO $con = null);
  328. } // NodePeer