AdminInterface.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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\Admin;
  11. use Sonata\AdminBundle\Admin\Pool;
  12. use Sonata\AdminBundle\Admin\FieldDescriptionInterface;
  13. use Sonata\AdminBundle\Builder\FormContractorInterface;
  14. use Sonata\AdminBundle\Builder\ListBuilderInterface;
  15. use Sonata\AdminBundle\Builder\DatagridBuilderInterface;
  16. use Sonata\AdminBundle\Security\Handler\SecurityHandlerInterface;
  17. use Sonata\AdminBundle\Builder\RouteBuilderInterface;
  18. use Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface;
  19. use Sonata\AdminBundle\Validator\ErrorElement;
  20. use Sonata\AdminBundle\Route\RouteGeneratorInterface;
  21. use Knp\Menu\FactoryInterface as MenuFactoryInterface;
  22. use Symfony\Component\Validator\ValidatorInterface;
  23. use Symfony\Component\Routing\RouterInterface;
  24. use Symfony\Component\Translation\TranslatorInterface;
  25. use Symfony\Component\HttpFoundation\Request;
  26. interface AdminInterface
  27. {
  28. /**
  29. * @param \Sonata\AdminBundle\Builder\FormContractorInterface $formContractor
  30. * @return void
  31. */
  32. function setFormContractor(FormContractorInterface $formContractor);
  33. /**
  34. * @param ListBuilderInterface $listBuilder
  35. * @return void
  36. */
  37. function setListBuilder(ListBuilderInterface $listBuilder);
  38. /**
  39. * @param \Sonata\AdminBundle\Builder\DatagridBuilderInterface $datagridBuilder
  40. * @return void
  41. */
  42. function setDatagridBuilder(DatagridBuilderInterface $datagridBuilder);
  43. /**
  44. * @param \Symfony\Component\Translation\TranslatorInterface $translator
  45. * @return void
  46. */
  47. function setTranslator(TranslatorInterface $translator);
  48. /**
  49. * @param \Symfony\Component\HttpFoundation\Request $request
  50. * @return void
  51. */
  52. function setRequest(Request $request);
  53. /**
  54. * @param Pool $pool
  55. * @return void
  56. */
  57. function setConfigurationPool(Pool $pool);
  58. /**
  59. * @param \Sonata\AdminBundle\Route\RouteGeneratorInterface $router
  60. * @return void
  61. */
  62. function setRouteGenerator(RouteGeneratorInterface $routeGenerator);
  63. /**
  64. * Returns the class name managed
  65. *
  66. * @return void
  67. */
  68. function getClass();
  69. /**
  70. * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  71. * @return void
  72. */
  73. function attachAdminClass(FieldDescriptionInterface $fieldDescription);
  74. /**
  75. * @return \Sonata\AdminBundle\Datagrid\DatagridInterface
  76. */
  77. function getDatagrid();
  78. /**
  79. * @param $name
  80. * @param array $parameters
  81. * @param bool $absolute
  82. * @return void
  83. */
  84. function generateUrl($name, array $parameters = array(), $absolute = false);
  85. /**
  86. * @return \Sonata\AdminBundle\ModelManagerInterface;
  87. */
  88. function getModelManager();
  89. /**
  90. * @return string the manager type of the admin
  91. */
  92. function getManagerType();
  93. /**
  94. * @return \Sonata\AdminBundle\Datagrid\ProxyQueryInterface
  95. */
  96. function createQuery($context = 'list');
  97. /**
  98. *
  99. * @return \Symfony\Component\Form\FormBuilder the form builder
  100. */
  101. function getFormBuilder();
  102. /**
  103. * @param string $name
  104. * @return \Sonata\AdminBundle\Admin\FieldDescriptionInterface
  105. */
  106. function getFormFieldDescription($name);
  107. /**
  108. * @return \Symfony\Component\HttpFoundation\Request
  109. */
  110. function getRequest();
  111. /**
  112. *
  113. * @return string
  114. */
  115. function getCode();
  116. /**
  117. * Return the roles and permissions per role
  118. * - different permissions per role for the acl handler
  119. * - one permission that has the same name as the role for the role handler
  120. * This should be used by experimented users
  121. *
  122. * @return array [role] => array([permission], [permission])
  123. */
  124. function getSecurityInformation();
  125. /**
  126. * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $parentFieldDescription
  127. * @return void
  128. */
  129. function setParentFieldDescription(FieldDescriptionInterface $parentFieldDescription);
  130. /**
  131. * translate a message id
  132. *
  133. * @param string $id
  134. * @param array $parameters
  135. * @param null $domain
  136. * @param null $locale
  137. * @return string the translated string
  138. */
  139. function trans($id, array $parameters = array(), $domain = null, $locale = null);
  140. /**
  141. * Return the parameter name used to represente the id in the url
  142. *
  143. * @return string
  144. */
  145. function getRouterIdParameter();
  146. /**
  147. * add a FieldDescription
  148. *
  149. * @param string $name
  150. * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  151. * @return void
  152. */
  153. function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription);
  154. /**
  155. * add a list FieldDescription
  156. *
  157. * @param string $name
  158. * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  159. * @return void
  160. */
  161. function addListFieldDescription($name, FieldDescriptionInterface $fieldDescription);
  162. /**
  163. * add a filter FieldDescription
  164. *
  165. * @param string $name
  166. * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
  167. * @return void
  168. */
  169. function addFilterFieldDescription($name, FieldDescriptionInterface $fieldDescription);
  170. /**
  171. * Returns a list depend on the given $object
  172. *
  173. * @return \Sonata\AdminBundle\Admin\FieldDescriptionCollection
  174. */
  175. function getList();
  176. /**
  177. * @param \Sonata\AdminBundle\Security\Handler\SecurityHandlerInterface $securityHandler
  178. * @return void
  179. */
  180. function setSecurityHandler(SecurityHandlerInterface $securityHandler);
  181. /**
  182. * @return \Sonata\AdminBundle\Security\Handler\SecurityHandlerInterface|null
  183. */
  184. function getSecurityHandler();
  185. /**
  186. * @param string $name
  187. * @param object|null $object
  188. * @return boolean
  189. */
  190. function isGranted($name, $object = null);
  191. /**
  192. * @param $entity
  193. */
  194. function getNormalizedIdentifier($entity);
  195. /**
  196. * Shorthand method for templating
  197. *
  198. * @param object $entity
  199. * @return mixed
  200. */
  201. function id($entity);
  202. /**
  203. * @param \Symfony\Component\Validator\ValidatorInterface $validator
  204. * @return void
  205. */
  206. function setValidator(ValidatorInterface $validator);
  207. /**
  208. * @return \Symfony\Component\Validator\ValidatorInterface
  209. */
  210. function getValidator();
  211. /**
  212. * @return array
  213. */
  214. function getShow();
  215. /**
  216. * @param array $formTheme
  217. * @return void
  218. */
  219. function setFormTheme(array $formTheme);
  220. /**
  221. * @return array
  222. */
  223. function getFormTheme();
  224. /**
  225. * @param array $filterTheme
  226. * @return void
  227. */
  228. function setFilterTheme(array $filterTheme);
  229. /**
  230. * @return array
  231. */
  232. function getFilterTheme();
  233. /**
  234. * @param AdminExtensionInterface $extension
  235. * @return void
  236. */
  237. function addExtension(AdminExtensionInterface $extension);
  238. /**
  239. * Returns an array of extension related to the current Admin
  240. *
  241. * @return void
  242. */
  243. function getExtensions();
  244. /**
  245. * @param \Knp\Menu\FactoryInterface $menuFactory
  246. * @return void
  247. */
  248. function setMenuFactory(MenuFactoryInterface $menuFactory);
  249. /**
  250. * @return \Knp\Menu\FactoryInterface
  251. */
  252. function getMenuFactory();
  253. /**
  254. * @param \Sonata\AdminBundle\Builder\RouteBuilderInterface $routeBuilder
  255. */
  256. function setRouteBuilder(RouteBuilderInterface $routeBuilder);
  257. /**
  258. * @return \Sonata\AdminBundle\Builder\RouteBuilderInterface
  259. */
  260. function getRouteBuilder();
  261. /**
  262. * @param $object
  263. * @return string
  264. */
  265. function toString($object);
  266. /**
  267. * @param \Sonata\Adminbundle\Translator\LabelTranslatorStrategyInterface $labelTranslatorStrategy
  268. */
  269. function setLabelTranslatorStrategy(LabelTranslatorStrategyInterface $labelTranslatorStrategy);
  270. /**
  271. * @return \Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface
  272. */
  273. function getLabelTranslatorStrategy();
  274. /**
  275. * add an Admin child to the current one
  276. *
  277. * @param \Sonata\AdminBundle\Admin\AdminInterface $child
  278. * @return void
  279. */
  280. function addChild(AdminInterface $child);
  281. /**
  282. * Returns true or false if an Admin child exists for the given $code
  283. *
  284. * @param string $code Admin code
  285. * @return bool True if child exist, false otherwise
  286. */
  287. function hasChild($code);
  288. /**
  289. * Returns an collection of admin children
  290. *
  291. * @return array list of Admin children
  292. */
  293. function getChildren();
  294. /**
  295. * Returns an admin child with the given $code
  296. *
  297. * @param string $code
  298. * @return array|null
  299. */
  300. function getChild($code);
  301. /**
  302. * @return object a new object instance
  303. */
  304. function getNewInstance();
  305. function setUniqid($uniqId);
  306. function getObject($id);
  307. function setSubject($subject);
  308. function getSubject();
  309. /**
  310. * Returns a list FieldDescription
  311. *
  312. * @param string $name
  313. * @return \Sonata\AdminBundle\Admin\FieldDescriptionInterface
  314. */
  315. function getListFieldDescription($name);
  316. function configure();
  317. function update($object);
  318. function create($object);
  319. function delete($object);
  320. function preUpdate($object);
  321. function postUpdate($object);
  322. function prePersist($object);
  323. function postPersist($object);
  324. function preRemove($object);
  325. function postRemove($object);
  326. /**
  327. * Return true if the Admin is related to a subject
  328. *
  329. * @return boolean
  330. */
  331. function hasSubject();
  332. /**
  333. * @param \Sonata\AdminBundle\Validator\ErrorElement $errorElement
  334. * @param $object
  335. * @return void
  336. */
  337. function validate(ErrorElement $errorElement, $object);
  338. /**
  339. * @param $context
  340. * @return boolean
  341. */
  342. function showIn($context);
  343. /**
  344. * Add object security, fe. make the current user owner of the object
  345. *
  346. * @param $object
  347. */
  348. function createObjectSecurity($object);
  349. /**
  350. * Returns the url defined by the $name
  351. *
  352. * @param strinf $name
  353. * @return Route
  354. */
  355. function getRoute($name);
  356. /**
  357. * @return AdminInterface
  358. */
  359. function getParent();
  360. /**
  361. * @param AdminInterface $admin
  362. * @return void
  363. */
  364. function setParent(AdminInterface $admin);
  365. }