FieldDescriptionInterface.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. interface FieldDescriptionInterface
  12. {
  13. /**
  14. * set the field name
  15. *
  16. * @param string $fieldName
  17. *
  18. * @return void
  19. */
  20. public function setFieldName($fieldName);
  21. /**
  22. * return the field name
  23. *
  24. * @return string the field name
  25. */
  26. public function getFieldName();
  27. /**
  28. * Set the name
  29. *
  30. * @param string $name
  31. *
  32. * @return void
  33. */
  34. public function setName($name);
  35. /**
  36. * Return the name, the name can be used as a form label or table header
  37. *
  38. * @return string the name
  39. */
  40. public function getName();
  41. /**
  42. * Return the value represented by the provided name
  43. *
  44. * @param string $name
  45. * @param null $default
  46. *
  47. * @return array|null the value represented by the provided name
  48. */
  49. public function getOption($name, $default = null);
  50. /**
  51. * Define an option, an option is has a name and a value
  52. *
  53. * @param string $name
  54. * @param mixed $value
  55. *
  56. * @return void set the option value
  57. */
  58. public function setOption($name, $value);
  59. /**
  60. * Define the options value, if the options array contains the reserved keywords
  61. * - type
  62. * - template
  63. *
  64. * Then the value are copied across to the related property value
  65. *
  66. * @param array $options
  67. *
  68. * @return void
  69. */
  70. public function setOptions(array $options);
  71. /**
  72. * return options
  73. *
  74. * @return array options
  75. */
  76. public function getOptions();
  77. /**
  78. * return the template used to render the field
  79. *
  80. * @param string $template
  81. *
  82. * @return void
  83. */
  84. public function setTemplate($template);
  85. /**
  86. * return the template name
  87. *
  88. * @return string the template name
  89. */
  90. public function getTemplate();
  91. /**
  92. * return the field type, the type is a mandatory field as it used to select the correct template
  93. * or the logic associated to the current FieldDescription object
  94. *
  95. * @param string $type
  96. *
  97. * @return void the field type
  98. */
  99. public function setType($type);
  100. /**
  101. * return the type
  102. *
  103. * @return int|string
  104. */
  105. public function getType();
  106. /**
  107. * set the parent Admin (only used in nested admin)
  108. *
  109. * @param \Sonata\AdminBundle\Admin\AdminInterface $parent
  110. *
  111. * @return void
  112. */
  113. public function setParent(AdminInterface $parent);
  114. /**
  115. * return the parent Admin (only used in nested admin)
  116. *
  117. * @return \Sonata\AdminBundle\Admin\AdminInterface
  118. */
  119. public function getParent();
  120. /**
  121. * Define the association mapping definition
  122. *
  123. * @param array $associationMapping
  124. *
  125. * @return void
  126. */
  127. public function setAssociationMapping($associationMapping);
  128. /**
  129. * return the association mapping definition
  130. *
  131. * @return array
  132. */
  133. public function getAssociationMapping();
  134. /**
  135. * return the related Target Entity
  136. *
  137. * @return string|null
  138. */
  139. public function getTargetEntity();
  140. /**
  141. * set the field mapping information
  142. *
  143. * @param array $fieldMapping
  144. *
  145. * @return void
  146. */
  147. public function setFieldMapping($fieldMapping);
  148. /**
  149. * return the field mapping definition
  150. *
  151. * @return array the field mapping definition
  152. */
  153. public function getFieldMapping();
  154. /**
  155. * set the parent association mappings information
  156. *
  157. * @param array $parentAssociationMappings
  158. *
  159. * @return void
  160. */
  161. public function setParentAssociationMappings(array $parentAssociationMappings);
  162. /**
  163. * return the parent association mapping definitions
  164. *
  165. * @return array the parent association mapping definitions
  166. */
  167. public function getParentAssociationMappings();
  168. /**
  169. * set the association admin instance (only used if the field is linked to an Admin)
  170. *
  171. * @param \Sonata\AdminBundle\Admin\AdminInterface $associationAdmin the associated admin
  172. */
  173. public function setAssociationAdmin(AdminInterface $associationAdmin);
  174. /**
  175. * return the associated Admin instance (only used if the field is linked to an Admin)
  176. * @return \Sonata\AdminBundle\Admin\AdminInterface
  177. */
  178. public function getAssociationAdmin();
  179. /**
  180. * return true if the FieldDescription is linked to an identifier field
  181. *
  182. * @return bool
  183. */
  184. public function isIdentifier();
  185. /**
  186. * return the value linked to the description
  187. *
  188. * @param mixed $object
  189. *
  190. * @return bool|mixed
  191. */
  192. public function getValue($object);
  193. /**
  194. * set the admin class linked to this FieldDescription
  195. *
  196. * @param \Sonata\AdminBundle\Admin\AdminInterface $admin
  197. *
  198. * @return void
  199. */
  200. public function setAdmin(AdminInterface $admin);
  201. /**
  202. * @return \Sonata\AdminBundle\Admin\AdminInterface the admin class linked to this FieldDescription
  203. */
  204. public function getAdmin();
  205. /**
  206. * merge option values related to the provided option name
  207. *
  208. * @throws \RuntimeException
  209. *
  210. * @param string $name
  211. * @param array $options
  212. *
  213. * @return void
  214. */
  215. public function mergeOption($name, array $options = array());
  216. /**
  217. * merge options values
  218. *
  219. * @param array $options
  220. *
  221. * @return void
  222. */
  223. public function mergeOptions(array $options = array());
  224. /**
  225. * set the original mapping type (only used if the field is linked to an entity)
  226. *
  227. * @param string|int $mappingType
  228. *
  229. * @return void
  230. */
  231. public function setMappingType($mappingType);
  232. /**
  233. * return the mapping type
  234. *
  235. * @return int|string
  236. */
  237. public function getMappingType();
  238. /**
  239. * return the label to use for the current field
  240. *
  241. * @return string
  242. */
  243. public function getLabel();
  244. /**
  245. * Return the translation domain to use for the current field.
  246. *
  247. * @return string
  248. */
  249. public function getTranslationDomain();
  250. /**
  251. * Return true if field is sortable.
  252. *
  253. * @return boolean
  254. */
  255. public function isSortable();
  256. /**
  257. * return the field mapping definition used when sorting
  258. *
  259. * @return array the field mapping definition
  260. */
  261. public function getSortFieldMapping();
  262. /**
  263. * return the parent association mapping definitions used when sorting
  264. *
  265. * @return array the parent association mapping definitions
  266. */
  267. public function getSortParentAssociationMapping();
  268. /**
  269. *
  270. * @param object $object
  271. * @param string $fieldName
  272. *
  273. * @return mixed
  274. */
  275. public function getFieldValue($object, $fieldName);
  276. }