FieldDescriptionInterface.php 6.3 KB

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