RepositoryInterface.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * @package Gedmo.Tree
  9. * @subpackage RepositoryInterface
  10. * @link http://www.gediminasm.org
  11. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  12. */
  13. interface RepositoryInterface extends RepositoryUtilsInterface
  14. {
  15. /**
  16. * Get all root nodes
  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. * @return array - list of given $node children, null on failure
  41. */
  42. public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false);
  43. /**
  44. * Counts the children of given TreeNode
  45. *
  46. * @param object $node - if null counts all records in tree
  47. * @param boolean $direct - true to count only direct children
  48. * @throws \Gedmo\Exception\InvalidArgumentException - if input is not valid
  49. * @return integer
  50. */
  51. public function childCount($node = null, $direct = false);
  52. }