RepositoryInterface.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace Gedmo\Tree;
  3. /**
  4. * This interface ensures a consisten 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. * @return array
  18. */
  19. public function getRootNodes($sortByField = null, $direction = 'asc');
  20. /**
  21. * Returns an array of nodes suitable for method buildTree
  22. *
  23. * @param object $node - Root node
  24. * @param bool $direct - Obtain direct children?
  25. * @param array $options - Options
  26. * @param boolean $includeNode - Include node in results?
  27. *
  28. * @return array - Array of nodes
  29. */
  30. public function getNodesHierarchy($node = null, $direct = false, array $options = array(), $includeNode = false);
  31. /**
  32. * Get list of children followed by given $node
  33. *
  34. * @param object $node - if null, all tree nodes will be taken
  35. * @param boolean $direct - true to take only direct children
  36. * @param string $sortByField - field name to sort by
  37. * @param string $direction - sort direction : "ASC" or "DESC"
  38. * @param bool $includeNode - Include the root node in results?
  39. * @return array - list of given $node children, null on failure
  40. */
  41. public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false);
  42. /**
  43. * Counts the children of given TreeNode
  44. *
  45. * @param object $node - if null counts all records in tree
  46. * @param boolean $direct - true to count only direct children
  47. * @throws \Gedmo\Exception\InvalidArgumentException - if input is not valid
  48. * @return integer
  49. */
  50. public function childCount($node = null, $direct = false);
  51. }