AdminExtensionInterface.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project 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\Admin;
  11. use Knp\Menu\ItemInterface as MenuItemInterface;
  12. use Sonata\AdminBundle\Datagrid\DatagridMapper;
  13. use Sonata\AdminBundle\Datagrid\ListMapper;
  14. use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
  15. use Sonata\AdminBundle\Form\FormMapper;
  16. use Sonata\AdminBundle\Route\RouteCollection;
  17. use Sonata\AdminBundle\Show\ShowMapper;
  18. use Sonata\CoreBundle\Validator\ErrorElement;
  19. /**
  20. * Interface AdminExtensionInterface.
  21. *
  22. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  23. */
  24. interface AdminExtensionInterface
  25. {
  26. /**
  27. * @param FormMapper $formMapper
  28. */
  29. public function configureFormFields(FormMapper $formMapper);
  30. /**
  31. * @param ListMapper $listMapper
  32. */
  33. public function configureListFields(ListMapper $listMapper);
  34. /**
  35. * @param DatagridMapper $datagridMapper
  36. */
  37. public function configureDatagridFilters(DatagridMapper $datagridMapper);
  38. /**
  39. * @param ShowMapper $showMapper
  40. */
  41. public function configureShowFields(ShowMapper $showMapper);
  42. /**
  43. * @param AdminInterface $admin
  44. * @param RouteCollection $collection
  45. */
  46. public function configureRoutes(AdminInterface $admin, RouteCollection $collection);
  47. /**
  48. * DEPRECATED: Use configureTabMenu instead.
  49. *
  50. * NEXT_MAJOR: remove this method.
  51. *
  52. * @param AdminInterface $admin
  53. * @param MenuItemInterface $menu
  54. * @param string $action
  55. * @param AdminInterface $childAdmin
  56. *
  57. * @deprecated
  58. */
  59. public function configureSideMenu(AdminInterface $admin, MenuItemInterface $menu, $action, AdminInterface $childAdmin = null);
  60. /**
  61. * Builds the tab menu.
  62. *
  63. * @param AdminInterface $admin
  64. * @param MenuItemInterface $menu
  65. * @param string $action
  66. * @param AdminInterface $childAdmin
  67. */
  68. public function configureTabMenu(AdminInterface $admin, MenuItemInterface $menu, $action, AdminInterface $childAdmin = null);
  69. /**
  70. * @param AdminInterface $admin
  71. * @param ErrorElement $errorElement
  72. * @param mixed $object
  73. */
  74. public function validate(AdminInterface $admin, ErrorElement $errorElement, $object);
  75. /**
  76. * @param AdminInterface $admin
  77. * @param ProxyQueryInterface $query
  78. * @param string $context
  79. */
  80. public function configureQuery(AdminInterface $admin, ProxyQueryInterface $query, $context = 'list');
  81. /**
  82. * Get a chance to modify a newly created instance.
  83. *
  84. * @param AdminInterface $admin
  85. * @param mixed $object
  86. */
  87. public function alterNewInstance(AdminInterface $admin, $object);
  88. /**
  89. * Get a chance to modify object instance.
  90. *
  91. * @param AdminInterface $admin
  92. * @param mixed $object
  93. */
  94. public function alterObject(AdminInterface $admin, $object);
  95. /**
  96. * Get a chance to add persistent parameters.
  97. *
  98. * @param AdminInterface $admin
  99. *
  100. * @return array
  101. */
  102. public function getPersistentParameters(AdminInterface $admin);
  103. /**
  104. * Return the controller access mapping.
  105. *
  106. * @param AdminInterface $admin
  107. *
  108. * @return array
  109. */
  110. // TODO: Uncomment in next major release
  111. // public function getAccessMapping(AdminInterface $admin);
  112. /**
  113. * Returns the list of batch actions.
  114. *
  115. * @param AdminInterface $admin
  116. * @param array $actions
  117. *
  118. * @return array
  119. */
  120. // TODO: Uncomment in next major release
  121. // public function configureBatchActions(AdminInterface $admin, array $actions);
  122. /**
  123. * Get a chance to modify export fields.
  124. *
  125. * @param AdminInterface $admin
  126. * @param string[] $fields
  127. *
  128. * @return string[]
  129. */
  130. // TODO: Uncomment in next major release
  131. // public function configureExportFields(AdminInterface $admin, array $fields);
  132. /**
  133. * @param AdminInterface $admin
  134. * @param mixed $object
  135. */
  136. public function preUpdate(AdminInterface $admin, $object);
  137. /**
  138. * @param AdminInterface $admin
  139. * @param mixed $object
  140. */
  141. public function postUpdate(AdminInterface $admin, $object);
  142. /**
  143. * @param AdminInterface $admin
  144. * @param mixed $object
  145. */
  146. public function prePersist(AdminInterface $admin, $object);
  147. /**
  148. * @param AdminInterface $admin
  149. * @param mixed $object
  150. */
  151. public function postPersist(AdminInterface $admin, $object);
  152. /**
  153. * @param AdminInterface $admin
  154. * @param mixed $object
  155. */
  156. public function preRemove(AdminInterface $admin, $object);
  157. /**
  158. * @param AdminInterface $admin
  159. * @param mixed $object
  160. */
  161. public function postRemove(AdminInterface $admin, $object);
  162. /*
  163. * Get all action buttons for an action
  164. *
  165. * @param AdminInterface $admin
  166. * @param array $list
  167. * @param string $action
  168. * @param mixed $object
  169. *
  170. * @return array
  171. */
  172. // TODO: Uncomment in next major release
  173. // public function configureActionButtons(AdminInterface $admin, $list, $action, $object);
  174. /*
  175. * NEXT_MAJOR: Uncomment in next major release
  176. *
  177. * Returns a list of default filters
  178. *
  179. * @param AdminInterface $admin
  180. * @param array $filterValues
  181. */
  182. // public function configureDefaultFilterValues(AdminInterface $admin, array &$filterValues);
  183. }