RepositoryUtilsInterface.php 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace Gedmo\Tree;
  3. interface RepositoryUtilsInterface
  4. {
  5. /**
  6. * Retrieves the nested array or the decorated output.
  7. *
  8. * Uses options to handle decorations
  9. *
  10. * @throws \Gedmo\Exception\InvalidArgumentException
  11. * @param object $node - from which node to start reordering the tree
  12. * @param boolean $direct - true to take only direct children
  13. * @param array $options :
  14. * decorate: boolean (false) - retrieves tree as UL->LI tree
  15. * nodeDecorator: Closure (null) - uses $node as argument and returns decorated item as string
  16. * rootOpen: string || Closure ('<ul>') - branch start, closure will be given $children as a parameter
  17. * rootClose: string ('</ul>') - branch close
  18. * childStart: string || Closure ('<li>') - start of node, closure will be given $node as a parameter
  19. * childClose: string ('</li>') - close of node
  20. * childSort: array || keys allowed: field: field to sort on, dir: direction. 'asc' or 'desc'
  21. * @param boolean $includeNode - Include node on results?
  22. *
  23. * @return array|string
  24. */
  25. public function childrenHierarchy($node = null, $direct = false, array $options = array(), $includeNode = false);
  26. /**
  27. * Retrieves the nested array or the decorated output.
  28. *
  29. * Uses options to handle decorations
  30. * NOTE: nodes should be fetched and hydrated as array
  31. *
  32. * @throws \Gedmo\Exception\InvalidArgumentException
  33. * @param array $nodes - list o nodes to build tree
  34. * @param array $options :
  35. * decorate: boolean (false) - retrieves tree as UL->LI tree
  36. * nodeDecorator: Closure (null) - uses $node as argument and returns decorated item as string
  37. * rootOpen: string || Closure ('<ul>') - branch start, closure will be given $children as a parameter
  38. * rootClose: string ('</ul>') - branch close
  39. * childStart: string || Closure ('<li>') - start of node, closure will be given $node as a parameter
  40. * childClose: string ('</li>') - close of node
  41. *
  42. * @return array|string
  43. */
  44. public function buildTree(array $nodes, array $options = array());
  45. /**
  46. * Process nodes and produce an array with the
  47. * structure of the tree
  48. *
  49. * @param array - Array of nodes
  50. *
  51. * @return array - Array with tree structure
  52. */
  53. public function buildTreeArray(array $nodes);
  54. /**
  55. * Sets the current children index.
  56. *
  57. * @param string $childrenIndex
  58. */
  59. public function setChildrenIndex($childrenIndex);
  60. /**
  61. * Gets the current children index.
  62. *
  63. * @return string
  64. */
  65. public function getChildrenIndex();
  66. }