AdminInterface.php 12 KB

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