FormConfigBuilderInterface.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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\EventSubscriberInterface;
  12. use Symfony\Component\PropertyAccess\PropertyPathInterface;
  13. /**
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. interface FormConfigBuilderInterface extends FormConfigInterface
  17. {
  18. /**
  19. * Adds an event listener to an event on this form.
  20. *
  21. * @param string $eventName The name of the event to listen to
  22. * @param callable $listener The listener to execute
  23. * @param int $priority The priority of the listener. Listeners
  24. * with a higher priority are called before
  25. * listeners with a lower priority.
  26. *
  27. * @return $this The configuration object
  28. */
  29. public function addEventListener($eventName, $listener, $priority = 0);
  30. /**
  31. * Adds an event subscriber for events on this form.
  32. *
  33. * @return $this The configuration object
  34. */
  35. public function addEventSubscriber(EventSubscriberInterface $subscriber);
  36. /**
  37. * Appends / prepends a transformer to the view transformer chain.
  38. *
  39. * The transform method of the transformer is used to convert data from the
  40. * normalized to the view format.
  41. * The reverseTransform method of the transformer is used to convert from the
  42. * view to the normalized format.
  43. *
  44. * @param DataTransformerInterface $viewTransformer
  45. * @param bool $forcePrepend If set to true, prepend instead of appending
  46. *
  47. * @return $this The configuration object
  48. */
  49. public function addViewTransformer(DataTransformerInterface $viewTransformer, $forcePrepend = false);
  50. /**
  51. * Clears the view transformers.
  52. *
  53. * @return $this The configuration object
  54. */
  55. public function resetViewTransformers();
  56. /**
  57. * Prepends / appends a transformer to the normalization transformer chain.
  58. *
  59. * The transform method of the transformer is used to convert data from the
  60. * model to the normalized format.
  61. * The reverseTransform method of the transformer is used to convert from the
  62. * normalized to the model format.
  63. *
  64. * @param DataTransformerInterface $modelTransformer
  65. * @param bool $forceAppend If set to true, append instead of prepending
  66. *
  67. * @return $this The configuration object
  68. */
  69. public function addModelTransformer(DataTransformerInterface $modelTransformer, $forceAppend = false);
  70. /**
  71. * Clears the normalization transformers.
  72. *
  73. * @return $this The configuration object
  74. */
  75. public function resetModelTransformers();
  76. /**
  77. * Sets the value for an attribute.
  78. *
  79. * @param string $name The name of the attribute
  80. * @param mixed $value The value of the attribute
  81. *
  82. * @return $this The configuration object
  83. */
  84. public function setAttribute($name, $value);
  85. /**
  86. * Sets the attributes.
  87. *
  88. * @return $this The configuration object
  89. */
  90. public function setAttributes(array $attributes);
  91. /**
  92. * Sets the data mapper used by the form.
  93. *
  94. * @return $this The configuration object
  95. */
  96. public function setDataMapper(DataMapperInterface $dataMapper = null);
  97. /**
  98. * Set whether the form is disabled.
  99. *
  100. * @param bool $disabled Whether the form is disabled
  101. *
  102. * @return $this The configuration object
  103. */
  104. public function setDisabled($disabled);
  105. /**
  106. * Sets the data used for the client data when no value is submitted.
  107. *
  108. * @param mixed $emptyData The empty data
  109. *
  110. * @return $this The configuration object
  111. */
  112. public function setEmptyData($emptyData);
  113. /**
  114. * Sets whether errors bubble up to the parent.
  115. *
  116. * @param bool $errorBubbling
  117. *
  118. * @return $this The configuration object
  119. */
  120. public function setErrorBubbling($errorBubbling);
  121. /**
  122. * Sets whether this field is required to be filled out when submitted.
  123. *
  124. * @param bool $required
  125. *
  126. * @return $this The configuration object
  127. */
  128. public function setRequired($required);
  129. /**
  130. * Sets the property path that the form should be mapped to.
  131. *
  132. * @param string|PropertyPathInterface|null $propertyPath The property path or null if the path should be set
  133. * automatically based on the form's name
  134. *
  135. * @return $this The configuration object
  136. */
  137. public function setPropertyPath($propertyPath);
  138. /**
  139. * Sets whether the form should be mapped to an element of its
  140. * parent's data.
  141. *
  142. * @param bool $mapped Whether the form should be mapped
  143. *
  144. * @return $this The configuration object
  145. */
  146. public function setMapped($mapped);
  147. /**
  148. * Sets whether the form's data should be modified by reference.
  149. *
  150. * @param bool $byReference Whether the data should be
  151. * modified by reference
  152. *
  153. * @return $this The configuration object
  154. */
  155. public function setByReference($byReference);
  156. /**
  157. * Sets whether the form should read and write the data of its parent.
  158. *
  159. * @param bool $inheritData Whether the form should inherit its parent's data
  160. *
  161. * @return $this The configuration object
  162. */
  163. public function setInheritData($inheritData);
  164. /**
  165. * Sets whether the form should be compound.
  166. *
  167. * @param bool $compound Whether the form should be compound
  168. *
  169. * @return $this The configuration object
  170. *
  171. * @see FormConfigInterface::getCompound()
  172. */
  173. public function setCompound($compound);
  174. /**
  175. * Set the types.
  176. *
  177. * @return $this The configuration object
  178. */
  179. public function setType(ResolvedFormTypeInterface $type);
  180. /**
  181. * Sets the initial data of the form.
  182. *
  183. * @param mixed $data The data of the form in application format
  184. *
  185. * @return $this The configuration object
  186. */
  187. public function setData($data);
  188. /**
  189. * Locks the form's data to the data passed in the configuration.
  190. *
  191. * A form with locked data is restricted to the data passed in
  192. * this configuration. The data can only be modified then by
  193. * submitting the form.
  194. *
  195. * @param bool $locked Whether to lock the default data
  196. *
  197. * @return $this The configuration object
  198. */
  199. public function setDataLocked($locked);
  200. /**
  201. * Sets the form factory used for creating new forms.
  202. */
  203. public function setFormFactory(FormFactoryInterface $formFactory);
  204. /**
  205. * Sets the target URL of the form.
  206. *
  207. * @param string $action The target URL of the form
  208. *
  209. * @return $this The configuration object
  210. */
  211. public function setAction($action);
  212. /**
  213. * Sets the HTTP method used by the form.
  214. *
  215. * @param string $method The HTTP method of the form
  216. *
  217. * @return $this The configuration object
  218. */
  219. public function setMethod($method);
  220. /**
  221. * Sets the request handler used by the form.
  222. *
  223. * @return $this The configuration object
  224. */
  225. public function setRequestHandler(RequestHandlerInterface $requestHandler);
  226. /**
  227. * Sets whether the form should be initialized automatically.
  228. *
  229. * Should be set to true only for root forms.
  230. *
  231. * @param bool $initialize True to initialize the form automatically,
  232. * false to suppress automatic initialization.
  233. * In the second case, you need to call
  234. * {@link FormInterface::initialize()} manually.
  235. *
  236. * @return $this The configuration object
  237. */
  238. public function setAutoInitialize($initialize);
  239. /**
  240. * Builds and returns the form configuration.
  241. *
  242. * @return FormConfigInterface
  243. */
  244. public function getFormConfig();
  245. }