FormFactoryInterface.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. /**
  12. * Allows creating a form based on a name, a class or a property.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. interface FormFactoryInterface
  17. {
  18. /**
  19. * Returns a form.
  20. *
  21. * @see createBuilder()
  22. *
  23. * @param mixed $data The initial data
  24. *
  25. * @return FormInterface The form named after the type
  26. *
  27. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
  28. */
  29. public function create(string $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = []);
  30. /**
  31. * Returns a form.
  32. *
  33. * @see createNamedBuilder()
  34. *
  35. * @param mixed $data The initial data
  36. *
  37. * @return FormInterface The form
  38. *
  39. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
  40. */
  41. public function createNamed(string $name, string $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = []);
  42. /**
  43. * Returns a form for a property of a class.
  44. *
  45. * @see createBuilderForProperty()
  46. *
  47. * @param string $class The fully qualified class name
  48. * @param string $property The name of the property to guess for
  49. * @param mixed $data The initial data
  50. *
  51. * @return FormInterface The form named after the property
  52. *
  53. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the form type
  54. */
  55. public function createForProperty(string $class, string $property, $data = null, array $options = []);
  56. /**
  57. * Returns a form builder.
  58. *
  59. * @param mixed $data The initial data
  60. *
  61. * @return FormBuilderInterface The form builder
  62. *
  63. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
  64. */
  65. public function createBuilder(string $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = []);
  66. /**
  67. * Returns a form builder.
  68. *
  69. * @param mixed $data The initial data
  70. *
  71. * @return FormBuilderInterface The form builder
  72. *
  73. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
  74. */
  75. public function createNamedBuilder(string $name, string $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = []);
  76. /**
  77. * Returns a form builder for a property of a class.
  78. *
  79. * If any of the 'required' and type options can be guessed,
  80. * and are not provided in the options argument, the guessed value is used.
  81. *
  82. * @param string $class The fully qualified class name
  83. * @param string $property The name of the property to guess for
  84. * @param mixed $data The initial data
  85. *
  86. * @return FormBuilderInterface The form builder named after the property
  87. *
  88. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the form type
  89. */
  90. public function createBuilderForProperty(string $class, string $property, $data = null, array $options = []);
  91. }