AdminExtensionInterface.php 5.6 KB

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