FieldDescriptionInterface.php 6.5 KB

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