FieldDescriptionInterface.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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 association admin instance (only used if the field is linked to an Admin)
  147. *
  148. * @param \Sonata\AdminBundle\Admin\AdminInterface $associationAdmin the associated admin
  149. */
  150. function setAssociationAdmin(AdminInterface $associationAdmin);
  151. /**
  152. * return the associated Admin instance (only used if the field is linked to an Admin)
  153. * @return \Sonata\AdminBundle\Admin\AdminInterface
  154. */
  155. function getAssociationAdmin();
  156. /**
  157. * return true if the FieldDescription is linked to an identifier field
  158. *
  159. * @return bool
  160. */
  161. function isIdentifier();
  162. /**
  163. * return the value linked to the description
  164. *
  165. * @param $object
  166. * @return bool|mixed
  167. */
  168. function getValue($object);
  169. /**
  170. * set the admin class linked to this FieldDescription
  171. *
  172. * @param \Sonata\AdminBundle\Admin\AdminInterface $admin
  173. * @return void
  174. */
  175. function setAdmin(AdminInterface $admin);
  176. /**
  177. * @return \Sonata\AdminBundle\Admin\AdminInterface the admin class linked to this FieldDescription
  178. */
  179. function getAdmin();
  180. /**
  181. * merge option values related to the provided option name
  182. *
  183. * @throws \RuntimeException
  184. * @param $name
  185. * @param array $options
  186. * @return void
  187. */
  188. function mergeOption($name, array $options = array());
  189. /**
  190. * merge options values
  191. *
  192. * @param array $options
  193. * @return void
  194. */
  195. function mergeOptions(array $options = array());
  196. /**
  197. * set the original mapping type (only used if the field is linked to an entity)
  198. *
  199. * @param string|int $mappingType
  200. * @return void
  201. */
  202. function setMappingType($mappingType);
  203. /**
  204. * return the mapping type
  205. *
  206. * @return int|string
  207. */
  208. function getMappingType();
  209. }