|
@@ -16,7 +16,6 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
|
|
use Symfony\Component\Form\Exception\AlreadyBoundException;
|
|
|
use Symfony\Component\Form\Exception\TransformationFailedException;
|
|
|
use Symfony\Component\Form\Util\FormUtil;
|
|
|
-use Symfony\Component\HttpFoundation\Request;
|
|
|
use Symfony\Component\PropertyAccess\PropertyPath;
|
|
|
|
|
|
/**
|
|
@@ -201,27 +200,6 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
return new PropertyPath($this->getName());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Returns the types used by this form.
|
|
|
- *
|
|
|
- * @return FormTypeInterface[] An array of FormTypeInterface
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
|
|
- * {@link getConfig()} and {@link FormConfigInterface::getType()} instead.
|
|
|
- */
|
|
|
- public function getTypes()
|
|
|
- {
|
|
|
- trigger_error('getTypes() is deprecated since version 2.1 and will be removed in 2.3. Use getConfig() and FormConfigInterface::getType() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- $types = array();
|
|
|
-
|
|
|
- for ($type = $this->config->getType(); null !== $type; $type = $type->getParent()) {
|
|
|
- array_unshift($types, $type->getInnerType());
|
|
|
- }
|
|
|
-
|
|
|
- return $types;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
@@ -272,21 +250,6 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
return $this->parent;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Returns whether the form has a parent.
|
|
|
- *
|
|
|
- * @return Boolean
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
|
|
- * {@link getParent()} or inverse {@link isRoot()} instead.
|
|
|
- */
|
|
|
- public function hasParent()
|
|
|
- {
|
|
|
- trigger_error('hasParent() is deprecated since version 2.1 and will be removed in 2.3. Use getParent() or inverse isRoot() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- return null !== $this->parent;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
@@ -303,40 +266,6 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
return null === $this->parent;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Returns whether the form has an attribute with the given name.
|
|
|
- *
|
|
|
- * @param string $name The name of the attribute.
|
|
|
- *
|
|
|
- * @return Boolean Whether the attribute exists.
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
|
|
- * {@link getConfig()} and {@link FormConfigInterface::hasAttribute()} instead.
|
|
|
- */
|
|
|
- public function hasAttribute($name)
|
|
|
- {
|
|
|
- trigger_error('hasAttribute() is deprecated since version 2.1 and will be removed in 2.3. Use getConfig() and FormConfigInterface::hasAttribute() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- return $this->config->hasAttribute($name);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Returns the value of the attributes with the given name.
|
|
|
- *
|
|
|
- * @param string $name The name of the attribute
|
|
|
- *
|
|
|
- * @return mixed The attribute value.
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
|
|
- * {@link getConfig()} and {@link FormConfigInterface::getAttribute()} instead.
|
|
|
- */
|
|
|
- public function getAttribute($name)
|
|
|
- {
|
|
|
- trigger_error('getAttribute() is deprecated since version 2.1 and will be removed in 2.3. Use getConfig() and FormConfigInterface::getAttribute() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- return $this->config->getAttribute($name);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
@@ -366,14 +295,9 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
$dispatcher = $this->config->getEventDispatcher();
|
|
|
|
|
|
// Hook to change content of the data
|
|
|
- if ($dispatcher->hasListeners(FormEvents::PRE_SET_DATA) || $dispatcher->hasListeners(FormEvents::SET_DATA)) {
|
|
|
+ if ($dispatcher->hasListeners(FormEvents::PRE_SET_DATA)) {
|
|
|
$event = new FormEvent($this, $modelData);
|
|
|
$dispatcher->dispatch(FormEvents::PRE_SET_DATA, $event);
|
|
|
- // BC until 2.3
|
|
|
- if ($dispatcher->hasListeners(FormEvents::SET_DATA)) {
|
|
|
- trigger_error('The FormEvents::SET_DATA event is deprecated since 2.1 and will be removed in 2.3. Use the FormEvents::PRE_SET_DATA event instead.', E_USER_DEPRECATED);
|
|
|
- }
|
|
|
- $dispatcher->dispatch(FormEvents::SET_DATA, $event);
|
|
|
$modelData = $event->getData();
|
|
|
}
|
|
|
|
|
@@ -472,21 +396,6 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
return $this->viewData;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Alias of {@link getViewData()}.
|
|
|
- *
|
|
|
- * @return string
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
|
|
- * {@link getViewData()} instead.
|
|
|
- */
|
|
|
- public function getClientData()
|
|
|
- {
|
|
|
- trigger_error('getClientData() is deprecated since version 2.1 and will be removed in 2.3. Use getViewData() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- return $this->getViewData();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
@@ -532,14 +441,9 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
$dispatcher = $this->config->getEventDispatcher();
|
|
|
|
|
|
// Hook to change content of the data bound by the browser
|
|
|
- if ($dispatcher->hasListeners(FormEvents::PRE_BIND) || $dispatcher->hasListeners(FormEvents::BIND_CLIENT_DATA)) {
|
|
|
+ if ($dispatcher->hasListeners(FormEvents::PRE_BIND)) {
|
|
|
$event = new FormEvent($this, $submittedData);
|
|
|
$dispatcher->dispatch(FormEvents::PRE_BIND, $event);
|
|
|
- // BC until 2.3
|
|
|
- if ($dispatcher->hasListeners(FormEvents::BIND_CLIENT_DATA)) {
|
|
|
- trigger_error('The FormEvents::BIND_CLIENT_DATA event is deprecated since 2.1 and will be removed in 2.3. Use the FormEvents::PRE_BIND event instead.', E_USER_DEPRECATED);
|
|
|
- }
|
|
|
- $dispatcher->dispatch(FormEvents::BIND_CLIENT_DATA, $event);
|
|
|
$submittedData = $event->getData();
|
|
|
}
|
|
|
|
|
@@ -595,14 +499,9 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
|
|
|
// Hook to change content of the data into the normalized
|
|
|
// representation
|
|
|
- if ($dispatcher->hasListeners(FormEvents::BIND) || $dispatcher->hasListeners(FormEvents::BIND_NORM_DATA)) {
|
|
|
+ if ($dispatcher->hasListeners(FormEvents::BIND)) {
|
|
|
$event = new FormEvent($this, $normData);
|
|
|
$dispatcher->dispatch(FormEvents::BIND, $event);
|
|
|
- // BC until 2.3
|
|
|
- if ($dispatcher->hasListeners(FormEvents::BIND_NORM_DATA)) {
|
|
|
- trigger_error('The FormEvents::BIND_NORM_DATA event is deprecated since 2.1 and will be removed in 2.3. Use the FormEvents::BIND event instead.', E_USER_DEPRECATED);
|
|
|
- }
|
|
|
- $dispatcher->dispatch(FormEvents::BIND_NORM_DATA, $event);
|
|
|
$normData = $event->getData();
|
|
|
}
|
|
|
|
|
@@ -623,41 +522,9 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
$dispatcher->dispatch(FormEvents::POST_BIND, $event);
|
|
|
}
|
|
|
|
|
|
- set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
|
|
|
- $validators = $this->config->getValidators();
|
|
|
- restore_error_handler();
|
|
|
-
|
|
|
- foreach ($validators as $validator) {
|
|
|
- trigger_error(sprintf('FormConfigInterface::getValidators() is deprecated since 2.1 and will be removed in 2.3. Convert your %s class to a listener on the FormEvents::POST_BIND event.', get_class($validator)), E_USER_DEPRECATED);
|
|
|
-
|
|
|
- $validator->validate($this);
|
|
|
- }
|
|
|
-
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Binds a request to the form.
|
|
|
- *
|
|
|
- * If the request method is POST, PUT or GET, the data is bound to the form,
|
|
|
- * transformed and written into the form data (an object or an array).
|
|
|
- *
|
|
|
- * @param Request $request The request to bind to the form
|
|
|
- *
|
|
|
- * @return Form This form
|
|
|
- *
|
|
|
- * @throws FormException if the method of the request is not one of GET, POST or PUT
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
|
|
- * {@link FormConfigInterface::bind()} instead.
|
|
|
- */
|
|
|
- public function bindRequest(Request $request)
|
|
|
- {
|
|
|
- trigger_error('bindRequest() is deprecated since version 2.1 and will be removed in 2.3. Use FormConfigInterface::bind() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- return $this->bind($request);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
@@ -672,21 +539,6 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Returns whether errors bubble up to the parent.
|
|
|
- *
|
|
|
- * @return Boolean
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
|
|
- * {@link getConfig()} and {@link FormConfigInterface::getErrorBubbling()} instead.
|
|
|
- */
|
|
|
- public function getErrorBubbling()
|
|
|
- {
|
|
|
- trigger_error('getErrorBubbling() is deprecated since version 2.1 and will be removed in 2.3. Use getConfig() and FormConfigInterface::getErrorBubbling() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- return $this->config->getErrorBubbling();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
@@ -745,21 +597,6 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Returns whether there are errors associated with this form.
|
|
|
- *
|
|
|
- * @return Boolean
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Count
|
|
|
- * {@link getErrors()} instead.
|
|
|
- */
|
|
|
- public function hasErrors()
|
|
|
- {
|
|
|
- trigger_error('hasErrors() is deprecated since version 2.1 and will be removed in 2.3. Count getErrors() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- return count($this->errors) > 0;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
@@ -796,36 +633,6 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
return $errors;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Returns the model transformers of the form.
|
|
|
- *
|
|
|
- * @return DataTransformerInterface[] An array of DataTransformerInterface
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
|
|
- * {@link getConfig()} and {@link FormConfigInterface::getModelTransformers()} instead.
|
|
|
- */
|
|
|
- public function getNormTransformers()
|
|
|
- {
|
|
|
- trigger_error('getNormTransformers() is deprecated since version 2.1 and will be removed in 2.3. Use getConfig() and FormConfigInterface::getModelTransformers() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- return $this->config->getModelTransformers();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Returns the view transformers of the form.
|
|
|
- *
|
|
|
- * @return DataTransformerInterface[] An array of DataTransformerInterface
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
|
|
- * {@link getConfig()} and {@link FormConfigInterface::getViewTransformers()} instead.
|
|
|
- */
|
|
|
- public function getClientTransformers()
|
|
|
- {
|
|
|
- trigger_error('getClientTransformers() is deprecated since version 2.1 and will be removed in 2.3. Use getConfig() and FormConfigInterface::getViewTransformers() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- return $this->config->getViewTransformers();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|
|
@@ -834,36 +641,6 @@ class Form implements \IteratorAggregate, FormInterface
|
|
|
return $this->children;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Returns all children in this group.
|
|
|
- *
|
|
|
- * @return array
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
|
|
- * {@link all()} instead.
|
|
|
- */
|
|
|
- public function getChildren()
|
|
|
- {
|
|
|
- trigger_error('getChildren() is deprecated since version 2.1 and will be removed in 2.3. Use all() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- return $this->all();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Returns whether the form has children.
|
|
|
- *
|
|
|
- * @return Boolean
|
|
|
- *
|
|
|
- * @deprecated Deprecated since version 2.1, to be removed in 2.3. Use
|
|
|
- * {@link count()} instead.
|
|
|
- */
|
|
|
- public function hasChildren()
|
|
|
- {
|
|
|
- trigger_error('hasChildren() is deprecated since version 2.1 and will be removed in 2.3. Use count() instead.', E_USER_DEPRECATED);
|
|
|
-
|
|
|
- return count($this->children) > 0;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|