AdminInterface.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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 string
  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 getUrlsafeIdentifier($entity);
  213. /**
  214. * @param mixed $entity
  215. */
  216. function getNormalizedIdentifier($entity);
  217. /**
  218. * Shorthand method for templating
  219. *
  220. * @param object $entity
  221. *
  222. * @return mixed
  223. */
  224. function id($entity);
  225. /**
  226. * @param \Symfony\Component\Validator\ValidatorInterface $validator
  227. *
  228. * @return void
  229. */
  230. function setValidator(ValidatorInterface $validator);
  231. /**
  232. * @return \Symfony\Component\Validator\ValidatorInterface
  233. */
  234. function getValidator();
  235. /**
  236. * @return array
  237. */
  238. function getShow();
  239. /**
  240. * @param array $formTheme
  241. *
  242. * @return void
  243. */
  244. function setFormTheme(array $formTheme);
  245. /**
  246. * @return array
  247. */
  248. function getFormTheme();
  249. /**
  250. * @param array $filterTheme
  251. *
  252. * @return void
  253. */
  254. function setFilterTheme(array $filterTheme);
  255. /**
  256. * @return array
  257. */
  258. function getFilterTheme();
  259. /**
  260. * @param AdminExtensionInterface $extension
  261. *
  262. * @return void
  263. */
  264. function addExtension(AdminExtensionInterface $extension);
  265. /**
  266. * Returns an array of extension related to the current Admin
  267. *
  268. * @return void
  269. */
  270. function getExtensions();
  271. /**
  272. * @param \Knp\Menu\FactoryInterface $menuFactory
  273. *
  274. * @return void
  275. */
  276. function setMenuFactory(MenuFactoryInterface $menuFactory);
  277. /**
  278. * @return \Knp\Menu\FactoryInterface
  279. */
  280. function getMenuFactory();
  281. /**
  282. * @param \Sonata\AdminBundle\Builder\RouteBuilderInterface $routeBuilder
  283. */
  284. function setRouteBuilder(RouteBuilderInterface $routeBuilder);
  285. /**
  286. * @return \Sonata\AdminBundle\Builder\RouteBuilderInterface
  287. */
  288. function getRouteBuilder();
  289. /**
  290. * @param mixed $object
  291. *
  292. * @return string
  293. */
  294. function toString($object);
  295. /**
  296. * @param \Sonata\Adminbundle\Translator\LabelTranslatorStrategyInterface $labelTranslatorStrategy
  297. */
  298. function setLabelTranslatorStrategy(LabelTranslatorStrategyInterface $labelTranslatorStrategy);
  299. /**
  300. * @return \Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface
  301. */
  302. function getLabelTranslatorStrategy();
  303. /**
  304. * add an Admin child to the current one
  305. *
  306. * @param \Sonata\AdminBundle\Admin\AdminInterface $child
  307. *
  308. * @return void
  309. */
  310. function addChild(AdminInterface $child);
  311. /**
  312. * Returns true or false if an Admin child exists for the given $code
  313. *
  314. * @param string $code Admin code
  315. *
  316. * @return bool True if child exist, false otherwise
  317. */
  318. function hasChild($code);
  319. /**
  320. * Returns an collection of admin children
  321. *
  322. * @return array list of Admin children
  323. */
  324. function getChildren();
  325. /**
  326. * Returns an admin child with the given $code
  327. *
  328. * @param string $code
  329. *
  330. * @return array|null
  331. */
  332. function getChild($code);
  333. /**
  334. * @return mixed a new object instance
  335. */
  336. function getNewInstance();
  337. /**
  338. * @param string $uniqId
  339. *
  340. * @return mixed
  341. */
  342. function setUniqid($uniqId);
  343. /**
  344. * @param mixed $id
  345. *
  346. * @return mixed
  347. */
  348. function getObject($id);
  349. /**
  350. * @param string $subject
  351. *
  352. * @return mixed
  353. */
  354. function setSubject($subject);
  355. /**
  356. * @return mixed
  357. */
  358. function getSubject();
  359. /**
  360. * Returns a list FieldDescription
  361. *
  362. * @param string $name
  363. *
  364. * @return \Sonata\AdminBundle\Admin\FieldDescriptionInterface
  365. */
  366. function getListFieldDescription($name);
  367. /**
  368. * @return void
  369. */
  370. function configure();
  371. /**
  372. * @param mixed $object
  373. *
  374. * @return mixed
  375. */
  376. function update($object);
  377. /**
  378. * @param mixed $object
  379. *
  380. * @return mixed
  381. */
  382. function create($object);
  383. /**
  384. * @param mixed $object
  385. *
  386. * @return mixed
  387. */
  388. function delete($object);
  389. /**
  390. * @param mixed $object
  391. *
  392. * @return mixed
  393. */
  394. function preUpdate($object);
  395. /**
  396. * @param mixed $object
  397. *
  398. * @return mixed
  399. */
  400. function postUpdate($object);
  401. /**
  402. * @param mixed $object
  403. *
  404. * @return mixed
  405. */
  406. function prePersist($object);
  407. /**
  408. * @param mixed $object
  409. *
  410. * @return mixed
  411. */
  412. function postPersist($object);
  413. /**
  414. * @param mixed $object
  415. *
  416. * @return mixed
  417. */
  418. function preRemove($object);
  419. /**
  420. * @param mixed $object
  421. *
  422. * @return mixed
  423. */
  424. function postRemove($object);
  425. /**
  426. * Return true if the Admin is related to a subject
  427. *
  428. * @return boolean
  429. */
  430. function hasSubject();
  431. /**
  432. * @param \Sonata\AdminBundle\Validator\ErrorElement $errorElement
  433. * @param mixed $object
  434. *
  435. * @return void
  436. */
  437. function validate(ErrorElement $errorElement, $object);
  438. /**
  439. * @param string $context
  440. *
  441. * @return boolean
  442. */
  443. function showIn($context);
  444. /**
  445. * Add object security, fe. make the current user owner of the object
  446. *
  447. * @param mixed $object
  448. */
  449. function createObjectSecurity($object);
  450. /**
  451. * Returns the url defined by the $name
  452. *
  453. * @param string $name
  454. *
  455. * @return \Symfony\Component\Routing\Route
  456. */
  457. function getRoute($name);
  458. /**
  459. * @return AdminInterface
  460. */
  461. function getParent();
  462. /**
  463. * @param AdminInterface $admin
  464. *
  465. * @return void
  466. */
  467. function setParent(AdminInterface $admin);
  468. /**
  469. * @param string $name
  470. *
  471. * @return null|string
  472. */
  473. public function getTemplate($name);
  474. }