RepositoryInterface.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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
  14. {
  15. /**
  16. * Get all root nodes query builder
  17. *
  18. * @return object - QueryBuilder object
  19. */
  20. public function getRootNodesQueryBuilder($sortByField = null, $direction = 'asc');
  21. /**
  22. * Get all root nodes query
  23. *
  24. * @return object - Query object
  25. */
  26. public function getRootNodesQuery($sortByField = null, $direction = 'asc');
  27. /**
  28. * Get all root nodes
  29. *
  30. * @return array
  31. */
  32. public function getRootNodes($sortByField = null, $direction = 'asc');
  33. /**
  34. * Returns a QueryBuilder configured to return an array of nodes suitable for buildTree method
  35. *
  36. * @param object $node - Root node
  37. * @param bool $direct - Obtain direct children?
  38. * @param array $config - Metadata configuration
  39. * @param array $options - Options
  40. * @param boolean $includeNode - Include node in results?
  41. *
  42. * @return object - QueryBuilder object
  43. */
  44. public function getNodesHierarchyQueryBuilder($node = null, $direct, array $config, array $options = array(), $includeNode = false);
  45. /**
  46. * Returns a Query configured to return an array of nodes suitable for buildTree method
  47. *
  48. * @param object $node - Root node
  49. * @param bool $direct - Obtain direct children?
  50. * @param array $config - Metadata configuration
  51. * @param array $options - Options
  52. * @param boolean $includeNode - Include node in results?
  53. *
  54. * @return object - Query object
  55. */
  56. public function getNodesHierarchyQuery($node = null, $direct, array $config, array $options = array(), $includeNode = false);
  57. /**
  58. * Returns an array of nodes suitable for method buildTree
  59. *
  60. * @param object $node - Root node
  61. * @param bool $direct - Obtain direct children?
  62. * @param array $config - Metadata configuration
  63. * @param array $options - Options
  64. * @param boolean $includeNode - Include node in results?
  65. *
  66. * @return array - Array of nodes
  67. */
  68. public function getNodesHierarchy($node = null, $direct, array $config, array $options = array(), $includeNode = false);
  69. /**
  70. * Get list of children followed by given $node. This returns a QueryBuilder object
  71. *
  72. * @param object $node - if null, all tree nodes will be taken
  73. * @param boolean $direct - true to take only direct children
  74. * @param string $sortByField - field name to sort by
  75. * @param string $direction - sort direction : "ASC" or "DESC"
  76. * @param bool $includeNode - Include the root node in results?
  77. * @return object - QueryBuilder object
  78. */
  79. public function getChildrenQueryBuilder($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false);
  80. /**
  81. * Get list of children followed by given $node. This returns a Query
  82. *
  83. * @param object $node - if null, all tree nodes will be taken
  84. * @param boolean $direct - true to take only direct children
  85. * @param string $sortByField - field name to sort by
  86. * @param string $direction - sort direction : "ASC" or "DESC"
  87. * @param bool $includeNode - Include the root node in results?
  88. * @return object - Query object
  89. */
  90. public function getChildrenQuery($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false);
  91. /**
  92. * Get list of children followed by given $node
  93. *
  94. * @param object $node - if null, all tree nodes will be taken
  95. * @param boolean $direct - true to take only direct children
  96. * @param string $sortByField - field name to sort by
  97. * @param string $direction - sort direction : "ASC" or "DESC"
  98. * @param bool $includeNode - Include the root node in results?
  99. * @return array - list of given $node children, null on failure
  100. */
  101. public function getChildren($node = null, $direct = false, $sortByField = null, $direction = 'ASC', $includeNode = false);
  102. /**
  103. * @see \Gedmo\Tree\RepositoryUtilsInterface::childrenHierarchy
  104. */
  105. public function childrenHierarchy($node = null, $direct = false, array $options = array());
  106. /**
  107. * @see \Gedmo\Tree\RepositoryUtilsInterface::buildTree
  108. */
  109. public function buildTree(array $nodes, array $options = array());
  110. /**
  111. * @see \Gedmo\Tree\RepositoryUtilsInterface::buildTreeArray
  112. */
  113. public function buildTreeArray(array $nodes);
  114. }