RepositoryUtilsInterface.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. * @param boolean $includeNode - Include node on results?
  21. *
  22. * @return array|string
  23. */
  24. public function childrenHierarchy($node = null, $direct = false, array $options = array(), $includeNode = false);
  25. /**
  26. * Retrieves the nested array or the decorated output.
  27. * Uses @options to handle decorations
  28. * NOTE: @nodes should be fetched and hydrated as array
  29. *
  30. * @throws \Gedmo\Exception\InvalidArgumentException
  31. * @param array $nodes - list o nodes to build tree
  32. * @param array $options :
  33. * decorate: boolean (false) - retrieves tree as UL->LI tree
  34. * nodeDecorator: Closure (null) - uses $node as argument and returns decorated item as string
  35. * rootOpen: string || Closure ('<ul>') - branch start, closure will be given $children as a parameter
  36. * rootClose: string ('</ul>') - branch close
  37. * childStart: string || Closure ('<li>') - start of node, closure will be given $node as a parameter
  38. * childClose: string ('</li>') - close of node
  39. *
  40. * @return array|string
  41. */
  42. public function buildTree(array $nodes, array $options = array());
  43. /**
  44. * Process nodes and produce an array with the
  45. * structure of the tree
  46. *
  47. * @param array - Array of nodes
  48. *
  49. * @return array - Array with tree structure
  50. */
  51. public function buildTreeArray(array $nodes);
  52. }