RepositoryInterface.php 2.0 KB

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 $config - Metadata configuration
  27. * @param array $options - Options
  28. * @param boolean $includeNode - Include node in results?
  29. *
  30. * @return array - Array of nodes
  31. */
  32. public function getNodesHierarchy($node = null, $direct, array $config, array $options = array(), $includeNode = false);
  33. /**
  34. * Get list of children followed by given $node
  35. *
  36. * @param object $node - if null, all tree nodes will be taken
  37. * @param boolean $direct - true to take only direct children
  38. * @param string $sortByField - field name to sort by
  39. * @param string $direction - sort direction : "ASC" or "DESC"
  40. * @param bool $includeNode - Include the root node in results?
  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. * @throws InvalidArgumentException - if input is not valid
  50. * @return integer
  51. */
  52. public function childCount($node = null, $direct = false);
  53. }