FieldDescriptionInterface.php 6.6 KB

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