ModelManagerInterface.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\AdminBundle\Model;
  11. use Sonata\AdminBundle\Admin\FieldDescriptionInterface;
  12. use Sonata\AdminBundle\Datagrid\DatagridInterface;
  13. interface ModelManagerInterface
  14. {
  15. /**
  16. * Returns true if the model has a relation
  17. *
  18. * @abstract
  19. * @param string $name
  20. * @return booleab
  21. */
  22. function hasMetadata($name);
  23. /**
  24. *
  25. * @param string $name
  26. * @return \Doctrine\ORM\Mapping\ClassMetadataInfo
  27. */
  28. function getMetadata($name);
  29. /**
  30. * Returns a new FieldDescription
  31. *
  32. * @abstract
  33. * @param string $class
  34. * @param string $name
  35. * @param array $options
  36. * @return \Sonata\AdminBundle\Admin\FieldDescriptionInterface
  37. */
  38. function getNewFieldDescriptionInstance($class, $name, array $options = array());
  39. /**
  40. * @param $object
  41. * @return void
  42. */
  43. function create($object);
  44. /**
  45. * @param object $object
  46. * @return void
  47. */
  48. function update($object);
  49. /**
  50. * @param object $object
  51. * @return void
  52. */
  53. function delete($object);
  54. /**
  55. * @param string $class
  56. * @param array $criteria
  57. * @return object
  58. */
  59. function find($class, array $criteria = array());
  60. /**
  61. * @param string $class
  62. * @param integer $id
  63. * @return object
  64. */
  65. function findOne($class, $id);
  66. /**
  67. * @param string $class classname
  68. * @param array $idx
  69. * @return void
  70. */
  71. function batchDelete($class, $idx);
  72. /**
  73. * @abstract
  74. * @param $parentAssociationMapping
  75. * @param $class
  76. * @return void
  77. */
  78. function getParentFieldDescription($parentAssociationMapping, $class);
  79. /**
  80. * @abstract
  81. * @param string $class
  82. * @param string $alias
  83. * @return a query instance
  84. */
  85. function createQuery($class, $alias = 'o');
  86. /**
  87. * @abstract
  88. * @param string $class
  89. * @return string
  90. */
  91. function getModelIdentifier($class);
  92. /**
  93. *
  94. * @param object
  95. * @return mixed
  96. */
  97. function getIdentifierValues($model);
  98. /**
  99. *
  100. * @return array
  101. */
  102. function getIdentifierFieldNames($cass);
  103. /**
  104. * @abstract
  105. * @param string $class
  106. * @return void
  107. */
  108. function getModelInstance($class);
  109. /**
  110. * @abstract
  111. * @param string $class
  112. * @return void
  113. */
  114. function getModelCollectionInstance($class);
  115. /**
  116. * Removes an element from the collection
  117. *
  118. * @param mixed $collection
  119. * @param mixed $element
  120. * @return void
  121. */
  122. function collectionRemoveElement(&$collection, &$element);
  123. /**
  124. * Add an element from the collection
  125. *
  126. * @param mixed $collection
  127. * @param mixed $element
  128. * @return mixed
  129. */
  130. function collectionAddElement(&$collection, &$element);
  131. /**
  132. * Check if the element exists in the collection
  133. *
  134. * @param mixed $collection
  135. * @param mixed $element
  136. * @return boolean
  137. */
  138. function collectionHasElement(&$collection, &$element);
  139. /**
  140. * Clear the collection
  141. *
  142. * @param mixed $collection
  143. * @param mixed $element
  144. * @return mixed
  145. */
  146. function collectionClear(&$collection);
  147. /**
  148. * Returns the parameters used in the columns header
  149. *
  150. * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  151. * @param \Sonata\AdminBundle\Datagrid\DatagridInterface $datagrid
  152. * @return string
  153. */
  154. function getSortParameters(FieldDescriptionInterface $fieldDescription, DatagridInterface $datagrid);
  155. /**
  156. * @param sring $class
  157. * @return array
  158. */
  159. function getDefaultSortValues($class);
  160. /**
  161. * @abstract
  162. * @param string $class
  163. * @param array $array
  164. * @return void
  165. */
  166. function modelReverseTransform($class, array $array = array());
  167. /**
  168. * @abstract
  169. * @param string $class
  170. * @param object $instance
  171. * @return void
  172. */
  173. function modelTransform($class, $instance);
  174. /**
  175. * @abstract
  176. * @param mixed $query
  177. * @return void
  178. */
  179. function executeQuery($query);
  180. }