RepositoryUtilsInterface.php 3.0 KB

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