AdminInterface.php 14 KB

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