RepositoryInterface.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Gedmo\Tree;
  3. /**
  4. * This interface ensures a consistent api between repositories for the ORM and the ODM.
  5. *
  6. * @author Gustavo Falco <comfortablynumb84@gmail.com>
  7. * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
  8. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  9. */
  10. interface RepositoryInterface extends RepositoryUtilsInterface
  11. {
  12. /**
  13. * Get all root nodes
  14. *
  15. * @param string $sortByField
  16. * @param string $direction
  17. *
  18. * @return array
  19. */
  20. public function getRootNodes($sortByField = null, $direction = 'asc');
  21. /**
  22. * Returns an array of nodes suitable for method buildTree
  23. *
  24. * @param object $node - Root node
  25. * @param bool $direct - Obtain direct children?
  26. * @param array $options - Options
  27. * @param boolean $includeNode - Include node in results?
  28. *
  29. * @return array - Array of nodes
  30. */
  31. public function getNodesHierarchy($node = null, $direct = false, array $options = array(), $includeNode = false);
  32. /**
  33. * Get list of children followed by given $node
  34. *
  35. * @param object $node - if null, all tree nodes will be taken
  36. * @param boolean $direct - true to take only direct children
  37. * @param string $sortByField - field name to sort by
  38. * @param string $direction - sort direction : "ASC" or "DESC"
  39. * @param bool $includeNode - Include the root node in results?
  40. *
  41. * @return array - list of given $node children, null on failure
  42. */
  43. public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false);
  44. /**
  45. * Counts the children of given TreeNode
  46. *
  47. * @param object $node - if null counts all records in tree
  48. * @param boolean $direct - true to count only direct children
  49. *
  50. * @throws \Gedmo\Exception\InvalidArgumentException - if input is not valid
  51. *
  52. * @return integer
  53. */
  54. public function childCount($node = null, $direct = false);
  55. }