FormConfigInterface.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  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 Symfony\Component\Form;
  11. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  12. use Symfony\Component\PropertyAccess\PropertyPathInterface;
  13. /**
  14. * The configuration of a {@link Form} object.
  15. *
  16. * @author Bernhard Schussek <bschussek@gmail.com>
  17. */
  18. interface FormConfigInterface
  19. {
  20. /**
  21. * Returns the event dispatcher used to dispatch form events.
  22. *
  23. * @return EventDispatcherInterface The dispatcher
  24. */
  25. public function getEventDispatcher();
  26. /**
  27. * Returns the name of the form used as HTTP parameter.
  28. *
  29. * @return string The form name
  30. */
  31. public function getName();
  32. /**
  33. * Returns the property path that the form should be mapped to.
  34. *
  35. * @return PropertyPathInterface|null The property path
  36. */
  37. public function getPropertyPath();
  38. /**
  39. * Returns whether the form should be mapped to an element of its
  40. * parent's data.
  41. *
  42. * @return bool Whether the form is mapped
  43. */
  44. public function getMapped();
  45. /**
  46. * Returns whether the form's data should be modified by reference.
  47. *
  48. * @return bool Whether to modify the form's data by reference
  49. */
  50. public function getByReference();
  51. /**
  52. * Returns whether the form should read and write the data of its parent.
  53. *
  54. * @return bool Whether the form should inherit its parent's data
  55. */
  56. public function getInheritData();
  57. /**
  58. * Returns whether the form is compound.
  59. *
  60. * This property is independent of whether the form actually has
  61. * children. A form can be compound and have no children at all, like
  62. * for example an empty collection form.
  63. *
  64. * @return bool Whether the form is compound
  65. */
  66. public function getCompound();
  67. /**
  68. * Returns the form types used to construct the form.
  69. *
  70. * @return ResolvedFormTypeInterface The form's type
  71. */
  72. public function getType();
  73. /**
  74. * Returns the view transformers of the form.
  75. *
  76. * @return DataTransformerInterface[] An array of {@link DataTransformerInterface} instances
  77. */
  78. public function getViewTransformers();
  79. /**
  80. * Returns the model transformers of the form.
  81. *
  82. * @return DataTransformerInterface[] An array of {@link DataTransformerInterface} instances
  83. */
  84. public function getModelTransformers();
  85. /**
  86. * Returns the data mapper of the form.
  87. *
  88. * @return DataMapperInterface|null The data mapper
  89. */
  90. public function getDataMapper();
  91. /**
  92. * Returns whether the form is required.
  93. *
  94. * @return bool Whether the form is required
  95. */
  96. public function getRequired();
  97. /**
  98. * Returns whether the form is disabled.
  99. *
  100. * @return bool Whether the form is disabled
  101. */
  102. public function getDisabled();
  103. /**
  104. * Returns whether errors attached to the form will bubble to its parent.
  105. *
  106. * @return bool Whether errors will bubble up
  107. */
  108. public function getErrorBubbling();
  109. /**
  110. * Returns the data that should be returned when the form is empty.
  111. *
  112. * @return mixed The data returned if the form is empty
  113. */
  114. public function getEmptyData();
  115. /**
  116. * Returns additional attributes of the form.
  117. *
  118. * @return array An array of key-value combinations
  119. */
  120. public function getAttributes();
  121. /**
  122. * Returns whether the attribute with the given name exists.
  123. *
  124. * @param string $name The attribute name
  125. *
  126. * @return bool Whether the attribute exists
  127. */
  128. public function hasAttribute($name);
  129. /**
  130. * Returns the value of the given attribute.
  131. *
  132. * @param string $name The attribute name
  133. * @param mixed $default The value returned if the attribute does not exist
  134. *
  135. * @return mixed The attribute value
  136. */
  137. public function getAttribute($name, $default = null);
  138. /**
  139. * Returns the initial data of the form.
  140. *
  141. * @return mixed The initial form data
  142. */
  143. public function getData();
  144. /**
  145. * Returns the class of the form data or null if the data is scalar or an array.
  146. *
  147. * @return string|null The data class or null
  148. */
  149. public function getDataClass();
  150. /**
  151. * Returns whether the form's data is locked.
  152. *
  153. * A form with locked data is restricted to the data passed in
  154. * this configuration. The data can only be modified then by
  155. * submitting the form.
  156. *
  157. * @return bool Whether the data is locked
  158. */
  159. public function getDataLocked();
  160. /**
  161. * Returns the form factory used for creating new forms.
  162. *
  163. * @return FormFactoryInterface The form factory
  164. */
  165. public function getFormFactory();
  166. /**
  167. * Returns the target URL of the form.
  168. *
  169. * @return string The target URL of the form
  170. */
  171. public function getAction();
  172. /**
  173. * Returns the HTTP method used by the form.
  174. *
  175. * @return string The HTTP method of the form
  176. */
  177. public function getMethod();
  178. /**
  179. * Returns the request handler used by the form.
  180. *
  181. * @return RequestHandlerInterface The request handler
  182. */
  183. public function getRequestHandler();
  184. /**
  185. * Returns whether the form should be initialized upon creation.
  186. *
  187. * @return bool returns true if the form should be initialized
  188. * when created, false otherwise
  189. */
  190. public function getAutoInitialize();
  191. /**
  192. * Returns all options passed during the construction of the form.
  193. *
  194. * @return array The passed options
  195. */
  196. public function getOptions();
  197. /**
  198. * Returns whether a specific option exists.
  199. *
  200. * @param string $name The option name,
  201. *
  202. * @return bool Whether the option exists
  203. */
  204. public function hasOption($name);
  205. /**
  206. * Returns the value of a specific option.
  207. *
  208. * @param string $name The option name
  209. * @param mixed $default The value returned if the option does not exist
  210. *
  211. * @return mixed The option value
  212. */
  213. public function getOption($name, $default = null);
  214. }