FieldDescriptionInterface.php 6.6 KB

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