RepositoryUtilsInterface.php 2.3 KB

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