[Form] Fixed API docs and usage of FormBuilderInterface instead of FormBuilder
This commit is contained in:
parent
2e6cdd15c5
commit
1c4f632f60
@ -11,15 +11,28 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface DataMapperInterface
|
||||
{
|
||||
/**
|
||||
* @param dataClass $data
|
||||
* @param array $forms
|
||||
* Maps properties of some data to a list of forms.
|
||||
*
|
||||
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
|
||||
* @param mixed $data Structured data.
|
||||
* @param array $forms A list of {@link FormInterface} instances.
|
||||
*
|
||||
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported.
|
||||
*/
|
||||
function mapDataToForms($data, array $forms);
|
||||
|
||||
/**
|
||||
* Maps the data of a list of forms into the properties of some data.
|
||||
*
|
||||
* @param array $forms A list of {@link FormInterface} instances.
|
||||
* @param mixed $data Structured data.
|
||||
*
|
||||
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported.
|
||||
*/
|
||||
function mapFormsToData(array $forms, &$data);
|
||||
}
|
||||
|
@ -955,13 +955,9 @@ class Form implements \IteratorAggregate, FormInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a view.
|
||||
*
|
||||
* @param FormView $parent The parent view
|
||||
*
|
||||
* @return FormView The view
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createView(FormView $parent = null)
|
||||
public function createView(FormViewInterface $parent = null)
|
||||
{
|
||||
if (null === $parent && $this->parent) {
|
||||
$parent = $this->parent->createView();
|
||||
|
@ -109,7 +109,7 @@ class FormFactory implements FormFactoryInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function create($type, $data = null, array $options = array(), FormBuilder $parent = null)
|
||||
public function create($type, $data = null, array $options = array(), FormBuilderInterface $parent = null)
|
||||
{
|
||||
return $this->createBuilder($type, $data, $options, $parent)->getForm();
|
||||
}
|
||||
@ -117,7 +117,7 @@ class FormFactory implements FormFactoryInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createNamed($name, $type, $data = null, array $options = array(), FormBuilder $parent = null)
|
||||
public function createNamed($name, $type, $data = null, array $options = array(), FormBuilderInterface $parent = null)
|
||||
{
|
||||
return $this->createNamedBuilder($name, $type, $data, $options, $parent)->getForm();
|
||||
}
|
||||
@ -125,7 +125,7 @@ class FormFactory implements FormFactoryInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createForProperty($class, $property, $data = null, array $options = array(), FormBuilder $parent = null)
|
||||
public function createForProperty($class, $property, $data = null, array $options = array(), FormBuilderInterface $parent = null)
|
||||
{
|
||||
return $this->createBuilderForProperty($class, $property, $data, $options, $parent)->getForm();
|
||||
}
|
||||
@ -133,7 +133,7 @@ class FormFactory implements FormFactoryInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createBuilder($type, $data = null, array $options = array(), FormBuilder $parent = null)
|
||||
public function createBuilder($type, $data = null, array $options = array(), FormBuilderInterface $parent = null)
|
||||
{
|
||||
$name = is_object($type) ? $type->getName() : $type;
|
||||
|
||||
@ -143,7 +143,7 @@ class FormFactory implements FormFactoryInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createNamedBuilder($name, $type, $data = null, array $options = array(), FormBuilder $parent = null)
|
||||
public function createNamedBuilder($name, $type, $data = null, array $options = array(), FormBuilderInterface $parent = null)
|
||||
{
|
||||
if (!array_key_exists('data', $options)) {
|
||||
$options['data'] = $data;
|
||||
@ -217,7 +217,7 @@ class FormFactory implements FormFactoryInterface
|
||||
}
|
||||
|
||||
if (!$builder) {
|
||||
throw new TypeDefinitionException(sprintf('Type "%s" or any of its parents should return a FormBuilder instance from createBuilder()', $type->getName()));
|
||||
throw new TypeDefinitionException(sprintf('Type "%s" or any of its parents should return a FormBuilderInterface instance from createBuilder()', $type->getName()));
|
||||
}
|
||||
|
||||
$builder->setTypes($types);
|
||||
@ -239,7 +239,7 @@ class FormFactory implements FormFactoryInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createBuilderForProperty($class, $property, $data = null, array $options = array(), FormBuilder $parent = null)
|
||||
public function createBuilderForProperty($class, $property, $data = null, array $options = array(), FormBuilderInterface $parent = null)
|
||||
{
|
||||
if (!$this->guesser) {
|
||||
$this->loadGuesser();
|
||||
|
@ -11,6 +11,9 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface FormFactoryInterface
|
||||
{
|
||||
/**
|
||||
@ -21,13 +24,13 @@ interface FormFactoryInterface
|
||||
* @param string|FormTypeInterface $type The type of the form
|
||||
* @param mixed $data The initial data
|
||||
* @param array $options The options
|
||||
* @param FormBuilder $parent The parent builder
|
||||
* @param FormBuilderInterface $parent The parent builder
|
||||
*
|
||||
* @return FormInterface The form named after the type
|
||||
*
|
||||
* @throws Exception\FormException if any given option is not applicable to the given type
|
||||
*/
|
||||
function create($type, $data = null, array $options = array(), FormBuilder $parent = null);
|
||||
function create($type, $data = null, array $options = array(), FormBuilderInterface $parent = null);
|
||||
|
||||
/**
|
||||
* Returns a form.
|
||||
@ -38,30 +41,30 @@ interface FormFactoryInterface
|
||||
* @param string|FormTypeInterface $type The type of the form
|
||||
* @param mixed $data The initial data
|
||||
* @param array $options The options
|
||||
* @param FormBuilder $parent The parent builder
|
||||
* @param FormBuilderInterface $parent The parent builder
|
||||
*
|
||||
* @return FormInterface The form
|
||||
*
|
||||
* @throws Exception\FormException if any given option is not applicable to the given type
|
||||
*/
|
||||
function createNamed($name, $type, $data = null, array $options = array(), FormBuilder $parent = null);
|
||||
function createNamed($name, $type, $data = null, array $options = array(), FormBuilderInterface $parent = null);
|
||||
|
||||
/**
|
||||
* Returns a form for a property of a class.
|
||||
*
|
||||
* @see createBuilderForProperty()
|
||||
*
|
||||
* @param string $class The fully qualified class name
|
||||
* @param string $property The name of the property to guess for
|
||||
* @param mixed $data The initial data
|
||||
* @param array $options The options for the builder
|
||||
* @param FormBuilder $parent The parent builder
|
||||
* @param string $class The fully qualified class name
|
||||
* @param string $property The name of the property to guess for
|
||||
* @param mixed $data The initial data
|
||||
* @param array $options The options for the builder
|
||||
* @param FormBuilderInterface $parent The parent builder
|
||||
*
|
||||
* @return FormInterface The form named after the property
|
||||
*
|
||||
* @throws Exception\FormException if any given option is not applicable to the form type
|
||||
*/
|
||||
function createForProperty($class, $property, $data = null, array $options = array(), FormBuilder $parent = null);
|
||||
function createForProperty($class, $property, $data = null, array $options = array(), FormBuilderInterface $parent = null);
|
||||
|
||||
/**
|
||||
* Returns a form builder.
|
||||
@ -69,13 +72,13 @@ interface FormFactoryInterface
|
||||
* @param string|FormTypeInterface $type The type of the form
|
||||
* @param mixed $data The initial data
|
||||
* @param array $options The options
|
||||
* @param FormBuilder $parent The parent builder
|
||||
* @param FormBuilderInterface $parent The parent builder
|
||||
*
|
||||
* @return FormBuilder The form builder
|
||||
* @return FormBuilderInterface The form builder
|
||||
*
|
||||
* @throws Exception\FormException if any given option is not applicable to the given type
|
||||
*/
|
||||
function createBuilder($type, $data = null, array $options = array(), FormBuilder $parent = null);
|
||||
function createBuilder($type, $data = null, array $options = array(), FormBuilderInterface $parent = null);
|
||||
|
||||
/**
|
||||
* Returns a form builder.
|
||||
@ -84,13 +87,13 @@ interface FormFactoryInterface
|
||||
* @param string|FormTypeInterface $type The type of the form
|
||||
* @param mixed $data The initial data
|
||||
* @param array $options The options
|
||||
* @param FormBuilder $parent The parent builder
|
||||
* @param FormBuilderInterface $parent The parent builder
|
||||
*
|
||||
* @return FormBuilder The form builder
|
||||
* @return FormBuilderInterface The form builder
|
||||
*
|
||||
* @throws Exception\FormException if any given option is not applicable to the given type
|
||||
*/
|
||||
function createNamedBuilder($name, $type, $data = null, array $options = array(), FormBuilder $parent = null);
|
||||
function createNamedBuilder($name, $type, $data = null, array $options = array(), FormBuilderInterface $parent = null);
|
||||
|
||||
/**
|
||||
* Returns a form builder for a property of a class.
|
||||
@ -98,17 +101,17 @@ interface FormFactoryInterface
|
||||
* If any of the 'max_length', 'required' and type options can be guessed,
|
||||
* and are not provided in the options argument, the guessed value is used.
|
||||
*
|
||||
* @param string $class The fully qualified class name
|
||||
* @param string $property The name of the property to guess for
|
||||
* @param mixed $data The initial data
|
||||
* @param array $options The options for the builder
|
||||
* @param FormBuilder $parent The parent builder
|
||||
* @param string $class The fully qualified class name
|
||||
* @param string $property The name of the property to guess for
|
||||
* @param mixed $data The initial data
|
||||
* @param array $options The options for the builder
|
||||
* @param FormBuilderInterface $parent The parent builder
|
||||
*
|
||||
* @return FormBuilder The form builder named after the property
|
||||
* @return FormBuilderInterface The form builder named after the property
|
||||
*
|
||||
* @throws Exception\FormException if any given option is not applicable to the form type
|
||||
*/
|
||||
function createBuilderForProperty($class, $property, $data = null, array $options = array(), FormBuilder $parent = null);
|
||||
function createBuilderForProperty($class, $property, $data = null, array $options = array(), FormBuilderInterface $parent = null);
|
||||
|
||||
/**
|
||||
* Returns a type by name.
|
||||
|
@ -238,9 +238,9 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
|
||||
/**
|
||||
* Creates a view.
|
||||
*
|
||||
* @param FormView $parent The parent view
|
||||
* @param FormViewInterface $parent The parent view
|
||||
*
|
||||
* @return FormView The view
|
||||
* @return FormViewInterface The view
|
||||
*/
|
||||
function createView(FormView $parent = null);
|
||||
function createView(FormViewInterface $parent = null);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ interface FormTypeExtensionInterface
|
||||
/**
|
||||
* Overrides the default options from the extended type.
|
||||
*
|
||||
* @param OptionsResolver $resolver The resolver for the options.
|
||||
* @param OptionsResolverInterface $resolver The resolver for the options.
|
||||
*/
|
||||
function setDefaultOptions(OptionsResolverInterface $resolver);
|
||||
|
||||
|
@ -11,6 +11,9 @@
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface FormTypeGuesserInterface
|
||||
{
|
||||
/**
|
||||
@ -19,7 +22,7 @@ interface FormTypeGuesserInterface
|
||||
* @param string $class The fully qualified class name
|
||||
* @param string $property The name of the property to guess for
|
||||
*
|
||||
* @return TypeGuess A guess for the field's type and options
|
||||
* @return Guess\TypeGuess A guess for the field's type and options
|
||||
*/
|
||||
function guessType($class, $property);
|
||||
|
||||
@ -29,7 +32,7 @@ interface FormTypeGuesserInterface
|
||||
* @param string $class The fully qualified class name
|
||||
* @param string $property The name of the property to guess for
|
||||
*
|
||||
* @return Guess A guess for the field's required setting
|
||||
* @return Guess\Guess A guess for the field's required setting
|
||||
*/
|
||||
function guessRequired($class, $property);
|
||||
|
||||
@ -39,7 +42,7 @@ interface FormTypeGuesserInterface
|
||||
* @param string $class The fully qualified class name
|
||||
* @param string $property The name of the property to guess for
|
||||
*
|
||||
* @return Guess A guess for the field's maximum length
|
||||
* @return Guess\Guess A guess for the field's maximum length
|
||||
*/
|
||||
function guessMaxLength($class, $property);
|
||||
|
||||
@ -49,7 +52,7 @@ interface FormTypeGuesserInterface
|
||||
* @param string $class The fully qualified class name
|
||||
* @param string $property The name of the property to guess for
|
||||
*
|
||||
* @return Guess A guess for the field's minimum length
|
||||
* @return Guess\Guess A guess for the field's minimum length
|
||||
*
|
||||
* @deprecated Deprecated since version 2.1, to be removed in 2.3.
|
||||
*/
|
||||
@ -67,7 +70,7 @@ interface FormTypeGuesserInterface
|
||||
* @param string $class The fully qualified class name
|
||||
* @param string $property The name of the property to guess for
|
||||
*
|
||||
* @return Guess A guess for the field's required pattern
|
||||
* @return Guess\Guess A guess for the field's required pattern
|
||||
*/
|
||||
function guessPattern($class, $property);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ interface FormTypeInterface
|
||||
/**
|
||||
* Sets the default options for this type.
|
||||
*
|
||||
* @param OptionsResolver $resolver The resolver for the options.
|
||||
* @param OptionsResolverInterface $resolver The resolver for the options.
|
||||
*/
|
||||
function setDefaultOptions(OptionsResolverInterface $resolver);
|
||||
|
||||
|
Reference in New Issue
Block a user