ModelManagerInterface.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
  14. interface ModelManagerInterface
  15. {
  16. /**
  17. * Returns true if the model has a relation
  18. *
  19. * @abstract
  20. * @param string $name
  21. * @return booleab
  22. */
  23. function hasMetadata($name);
  24. /**
  25. *
  26. * @param string $name
  27. * @return \Doctrine\ORM\Mapping\ClassMetadataInfo
  28. */
  29. function getMetadata($name);
  30. /**
  31. * Returns a new FieldDescription
  32. *
  33. * @abstract
  34. * @param string $class
  35. * @param string $name
  36. * @param array $options
  37. * @return \Sonata\AdminBundle\Admin\FieldDescriptionInterface
  38. */
  39. function getNewFieldDescriptionInstance($class, $name, array $options = array());
  40. /**
  41. * @param $object
  42. * @return void
  43. */
  44. function create($object);
  45. /**
  46. * @param object $object
  47. * @return void
  48. */
  49. function update($object);
  50. /**
  51. * @param object $object
  52. * @return void
  53. */
  54. function delete($object);
  55. /**
  56. * @param string $class
  57. * @param array $criteria
  58. * @return object
  59. */
  60. function find($class, array $criteria = array());
  61. /**
  62. * @param string $class
  63. * @param integer $id
  64. * @return object
  65. */
  66. function findOne($class, $id);
  67. /**
  68. * @param string $class classname
  69. * @param array $idx
  70. * @return void
  71. */
  72. function batchDelete($class, ProxyQueryInterface $queryProxy);
  73. /**
  74. * @abstract
  75. * @param $parentAssociationMapping
  76. * @param $class
  77. * @return void
  78. */
  79. function getParentFieldDescription($parentAssociationMapping, $class);
  80. /**
  81. * @abstract
  82. * @param string $class
  83. * @param string $alias
  84. * @return a query instance
  85. */
  86. function createQuery($class, $alias = 'o');
  87. /**
  88. * @abstract
  89. * @param string $class
  90. * @return string
  91. */
  92. function getModelIdentifier($class);
  93. /**
  94. *
  95. * @param object $model
  96. * @return mixed
  97. */
  98. function getIdentifierValues($model);
  99. /**
  100. * @param string $class
  101. * @return array
  102. */
  103. function getIdentifierFieldNames($class);
  104. /**
  105. * @abstract
  106. * @param string $class
  107. * @return void
  108. */
  109. function getModelInstance($class);
  110. /**
  111. * @abstract
  112. * @param string $class
  113. * @return void
  114. */
  115. function getModelCollectionInstance($class);
  116. /**
  117. * Removes an element from the collection
  118. *
  119. * @param mixed $collection
  120. * @param mixed $element
  121. * @return void
  122. */
  123. function collectionRemoveElement(&$collection, &$element);
  124. /**
  125. * Add an element from the collection
  126. *
  127. * @param mixed $collection
  128. * @param mixed $element
  129. * @return mixed
  130. */
  131. function collectionAddElement(&$collection, &$element);
  132. /**
  133. * Check if the element exists in the collection
  134. *
  135. * @param mixed $collection
  136. * @param mixed $element
  137. * @return boolean
  138. */
  139. function collectionHasElement(&$collection, &$element);
  140. /**
  141. * Clear the collection
  142. *
  143. * @param mixed $collection
  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. }