FieldDescriptionInterface.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project 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. /**
  12. * Interface FieldDescriptionInterface.
  13. *
  14. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  15. */
  16. interface FieldDescriptionInterface
  17. {
  18. /**
  19. * set the field name.
  20. *
  21. * @param string $fieldName
  22. */
  23. public function setFieldName($fieldName);
  24. /**
  25. * return the field name.
  26. *
  27. * @return string the field name
  28. */
  29. public function getFieldName();
  30. /**
  31. * Set the name.
  32. *
  33. * @param string $name
  34. */
  35. public 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. public 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. public 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. public function setOption($name, $value);
  58. /**
  59. * Define the options value, if the options array contains the reserved keywords
  60. * - type
  61. * - template.
  62. *
  63. * Then the value are copied across to the related property value
  64. *
  65. * @param array $options
  66. */
  67. public function setOptions(array $options);
  68. /**
  69. * return options.
  70. *
  71. * @return array options
  72. */
  73. public function getOptions();
  74. /**
  75. * return the template used to render the field.
  76. *
  77. * @param string $template
  78. */
  79. public function setTemplate($template);
  80. /**
  81. * return the template name.
  82. *
  83. * @return string the template name
  84. */
  85. public 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. */
  92. public function setType($type);
  93. /**
  94. * return the type.
  95. *
  96. * @return int|string
  97. */
  98. public function getType();
  99. /**
  100. * set the parent Admin (only used in nested admin).
  101. *
  102. * @param AdminInterface $parent
  103. */
  104. public function setParent(AdminInterface $parent);
  105. /**
  106. * return the parent Admin (only used in nested admin).
  107. *
  108. * @return AdminInterface
  109. */
  110. public function getParent();
  111. /**
  112. * Define the association mapping definition.
  113. *
  114. * @param array $associationMapping
  115. */
  116. public function setAssociationMapping($associationMapping);
  117. /**
  118. * return the association mapping definition.
  119. *
  120. * @return array
  121. */
  122. public function getAssociationMapping();
  123. /**
  124. * return the related Target Entity.
  125. *
  126. * @return string|null
  127. */
  128. public function getTargetEntity();
  129. /**
  130. * set the field mapping information.
  131. *
  132. * @param array $fieldMapping
  133. */
  134. public function setFieldMapping($fieldMapping);
  135. /**
  136. * return the field mapping definition.
  137. *
  138. * @return array the field mapping definition
  139. */
  140. public function getFieldMapping();
  141. /**
  142. * set the parent association mappings information.
  143. *
  144. * @param array $parentAssociationMappings
  145. */
  146. public function setParentAssociationMappings(array $parentAssociationMappings);
  147. /**
  148. * return the parent association mapping definitions.
  149. *
  150. * @return array the parent association mapping definitions
  151. */
  152. public function getParentAssociationMappings();
  153. /**
  154. * set the association admin instance (only used if the field is linked to an Admin).
  155. *
  156. * @param AdminInterface $associationAdmin the associated admin
  157. */
  158. public function setAssociationAdmin(AdminInterface $associationAdmin);
  159. /**
  160. * return the associated Admin instance (only used if the field is linked to an Admin).
  161. *
  162. * @return AdminInterface
  163. */
  164. public function getAssociationAdmin();
  165. /**
  166. * return true if the FieldDescription is linked to an identifier field.
  167. *
  168. * @return bool
  169. */
  170. public function isIdentifier();
  171. /**
  172. * return the value linked to the description.
  173. *
  174. * @param mixed $object
  175. *
  176. * @return bool|mixed
  177. */
  178. public function getValue($object);
  179. /**
  180. * set the admin class linked to this FieldDescription.
  181. *
  182. * @param AdminInterface $admin
  183. */
  184. public function setAdmin(AdminInterface $admin);
  185. /**
  186. * @return AdminInterface the admin class linked to this FieldDescription
  187. */
  188. public function getAdmin();
  189. /**
  190. * merge option values related to the provided option name.
  191. *
  192. * @throws \RuntimeException
  193. *
  194. * @param string $name
  195. * @param array $options
  196. */
  197. public function mergeOption($name, array $options = array());
  198. /**
  199. * merge options values.
  200. *
  201. * @param array $options
  202. */
  203. public function mergeOptions(array $options = array());
  204. /**
  205. * set the original mapping type (only used if the field is linked to an entity).
  206. *
  207. * @param string|int $mappingType
  208. */
  209. public function setMappingType($mappingType);
  210. /**
  211. * return the mapping type.
  212. *
  213. * @return int|string
  214. */
  215. public function getMappingType();
  216. /**
  217. * return the label to use for the current field.
  218. *
  219. * @return string
  220. */
  221. public function getLabel();
  222. /**
  223. * Return the translation domain to use for the current field.
  224. *
  225. * @return string
  226. */
  227. public function getTranslationDomain();
  228. /**
  229. * Return true if field is sortable.
  230. *
  231. * @return bool
  232. */
  233. public function isSortable();
  234. /**
  235. * return the field mapping definition used when sorting.
  236. *
  237. * @return array the field mapping definition
  238. */
  239. public function getSortFieldMapping();
  240. /**
  241. * return the parent association mapping definitions used when sorting.
  242. *
  243. * @return array the parent association mapping definitions
  244. */
  245. public function getSortParentAssociationMapping();
  246. /**
  247. * @param object $object
  248. * @param string $fieldName
  249. *
  250. * @return mixed
  251. */
  252. public function getFieldValue($object, $fieldName);
  253. }