[Form] Trigger errors for deprecated methods in Form Component

This commit is contained in:
Colin Frei 2012-12-12 17:43:13 +01:00
parent f3d696636a
commit d5b2638ff4
15 changed files with 109 additions and 0 deletions

View File

@ -143,6 +143,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
*/
public function guessMinLength($class, $property)
{
trigger_error('guessMinLength() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
}
/**

View File

@ -126,6 +126,7 @@ class PropelTypeGuesser implements FormTypeGuesserInterface
*/
public function guessMinLength($class, $property)
{
trigger_error('guessMinLength() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
}
/**

View File

@ -67,6 +67,8 @@ abstract class AbstractType implements FormTypeInterface
*/
public function getDefaultOptions(array $options)
{
trigger_error('getDefaultOptions() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
return array();
}
@ -82,6 +84,8 @@ abstract class AbstractType implements FormTypeInterface
*/
public function getAllowedOptionValues(array $options)
{
trigger_error('getAllowedOptionValues() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
return array();
}
@ -104,6 +108,8 @@ abstract class AbstractType implements FormTypeInterface
*/
public function setExtensions(array $extensions)
{
trigger_error('setExtensions() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
$this->extensions = $extensions;
}
@ -117,6 +123,8 @@ abstract class AbstractType implements FormTypeInterface
*/
public function getExtensions()
{
trigger_error('getExtensions() is deprecated since version 2.1 and will be removed in 2.3. Use ResolvedFormTypeInterface::getTypeExtensions instead.', E_USER_DEPRECATED);
return $this->extensions;
}
}

View File

@ -58,6 +58,8 @@ abstract class AbstractTypeExtension implements FormTypeExtensionInterface
*/
public function getDefaultOptions()
{
trigger_error('getDefaultOptions() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
return array();
}
@ -71,6 +73,8 @@ abstract class AbstractTypeExtension implements FormTypeExtensionInterface
*/
public function getAllowedOptionValues()
{
trigger_error('getAllowedOptionValues() is deprecated since version 2.1 and will be removed in 2.3. Use setDefaultOptions() instead.', E_USER_DEPRECATED);
return array();
}
}

View File

@ -27,6 +27,8 @@ class CallbackValidator implements FormValidatorInterface
*/
public function __construct($callback)
{
trigger_error('CallbackValidator is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
$this->callback = $callback;
}
@ -35,6 +37,8 @@ class CallbackValidator implements FormValidatorInterface
*/
public function validate(FormInterface $form)
{
trigger_error('validate() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
return call_user_func($this->callback, $form);
}
}

View File

@ -33,6 +33,8 @@ class DataEvent extends Event
*/
public function __construct(FormInterface $form, $data)
{
trigger_error('DataEvent is deprecated since version 2.1 and will be removed in 2.3. Code against \Symfony\Component\Form\FormEvent instead.', E_USER_DEPRECATED);
$this->form = $form;
$this->data = $data;
}

View File

@ -22,6 +22,11 @@ use Symfony\Component\Form\AbstractType;
*/
class FieldType extends AbstractType
{
function __construct()
{
trigger_error('FieldType is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
}
/**
* {@inheritdoc}
*/

View File

@ -70,6 +70,7 @@ class ValidatorTypeGuesser implements FormTypeGuesserInterface
*/
public function guessMinLength($class, $property)
{
trigger_error('guessMinLength() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
}
/**

View File

@ -210,6 +210,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
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()) {
@ -279,6 +281,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
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;
}
@ -310,6 +314,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
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);
}
@ -325,6 +331,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
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);
}
@ -470,6 +478,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
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();
}
@ -627,6 +637,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
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);
}
@ -654,6 +666,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
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();
}
@ -721,6 +735,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
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;
}
@ -770,6 +786,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
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();
}
@ -783,6 +801,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
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();
}
@ -804,6 +824,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
public function getChildren()
{
trigger_error('getChilren() is deprecated since version 2.1 and will be removed in 2.3. Use all() instead.', E_USER_DEPRECATED);
return $this->all();
}
@ -817,6 +839,8 @@ class Form implements \IteratorAggregate, FormInterface
*/
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;
}

View File

@ -295,6 +295,8 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
*/
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->getType(); null !== $type; $type = $type->getParent()) {

View File

@ -196,6 +196,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
public function addValidator(FormValidatorInterface $validator)
{
trigger_error('addValidator() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
if ($this->locked) {
throw new FormException('The config builder cannot be modified anymore.');
}
@ -251,6 +253,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
public function appendClientTransformer(DataTransformerInterface $viewTransformer)
{
trigger_error('appendClientTransformer() is deprecated since version 2.1 and will be removed in 2.3. Use addViewTransformer() instead.', E_USER_DEPRECATED);
if ($this->locked) {
throw new FormException('The config builder cannot be modified anymore.');
}
@ -271,6 +275,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
public function prependClientTransformer(DataTransformerInterface $viewTransformer)
{
trigger_error('prependClientTransformer() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
if ($this->locked) {
throw new FormException('The config builder cannot be modified anymore.');
}
@ -290,6 +296,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
public function resetClientTransformers()
{
trigger_error('resetClientTransformers() is deprecated since version 2.1 and will be removed in 2.3. Use resetViewTransformers() instead.', E_USER_DEPRECATED);
if ($this->locked) {
throw new FormException('The config builder cannot be modified anymore.');
}
@ -342,6 +350,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
public function appendNormTransformer(DataTransformerInterface $modelTransformer)
{
trigger_error('appendNormTransformer() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
if ($this->locked) {
throw new FormException('The config builder cannot be modified anymore.');
}
@ -363,6 +373,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
public function prependNormTransformer(DataTransformerInterface $modelTransformer)
{
trigger_error('prependNormTransformer() is deprecated since version 2.1 and will be removed in 2.3. Use addModelTransformer() instead.', E_USER_DEPRECATED);
if ($this->locked) {
throw new FormException('The config builder cannot be modified anymore.');
}
@ -382,6 +394,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
public function resetNormTransformers()
{
trigger_error('resetNormTransformers() is deprecated since version 2.1 and will be removed in 2.3. Use resetModelTransformers() instead.', E_USER_DEPRECATED);
if ($this->locked) {
throw new FormException('The config builder cannot be modified anymore.');
}
@ -471,6 +485,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
public function getClientTransformers()
{
trigger_error('getClientTransformers() is deprecated since version 2.1 and will be removed in 2.3. Use getViewTransformers() instead.', E_USER_DEPRECATED);
return $this->getViewTransformers();
}
@ -492,6 +508,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
public function getNormTransformers()
{
trigger_error('getNormTransformers() is deprecated since version 2.1 and will be removed in 2.3. Use getModelTransformers() instead.', E_USER_DEPRECATED);
return $this->getModelTransformers();
}
@ -508,6 +526,8 @@ class FormConfigBuilder implements FormConfigBuilderInterface
*/
public function getValidators()
{
trigger_error('getValidators() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
return $this->validators;
}

View File

@ -146,6 +146,8 @@ class FormFactory implements FormFactoryInterface
*/
public function hasType($name)
{
trigger_error('hasType() is deprecated since version 2.1 and will be removed in 2.3. Use FormRegistryInterface::hasType() instead.', E_USER_DEPRECATED);
return $this->registry->hasType($name);
}
@ -160,6 +162,8 @@ class FormFactory implements FormFactoryInterface
*/
public function addType(FormTypeInterface $type)
{
trigger_error('addType() is deprecated since version 2.1 and will be removed in 2.3. Use form extensions or type registration in the Dependency Injection Container instead.', E_USER_DEPRECATED);
$parentType = $type->getParent();
$this->registry->addType($this->resolvedTypeFactory->createResolvedType(
@ -185,6 +189,8 @@ class FormFactory implements FormFactoryInterface
*/
public function getType($name)
{
trigger_error('getType() is deprecated since version 2.1 and will be removed in 2.3. Use FormRegistryInterface::getType() instead.', E_USER_DEPRECATED);
return $this->registry->getType($name)->getInnerType();
}

View File

@ -68,6 +68,8 @@ class FormRegistry implements FormRegistryInterface
*/
public function addType(ResolvedFormTypeInterface $type)
{
trigger_error('addType() is deprecated since version 2.1 and will be removed in 2.3. Use form extensions or type registration in the Dependency Injection Container instead.', E_USER_DEPRECATED);
$this->types[$type->getName()] = $type;
}

View File

@ -75,6 +75,8 @@ class FormTypeGuesserChain implements FormTypeGuesserInterface
*/
public function guessMinLength($class, $property)
{
trigger_error('guessMinLength() is deprecated since version 2.1 and will be removed in 2.3.', E_USER_DEPRECATED);
return $this->guess(function ($guesser) use ($class, $property) {
return $guesser->guessMinLength($class, $property);
});

View File

@ -64,6 +64,7 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function getName()
{
trigger_error('getName() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'vars\' instead which contains an entry named "name".', E_USER_DEPRECATED);
return $this->vars['name'];
}
@ -78,6 +79,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function set($name, $value)
{
trigger_error('set() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'vars\' instead.', E_USER_DEPRECATED);
$this->vars[$name] = $value;
return $this;
@ -93,6 +96,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function has($name)
{
trigger_error('has() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'vars\' instead.', E_USER_DEPRECATED);
return array_key_exists($name, $this->vars);
}
@ -107,6 +112,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function get($name, $default = null)
{
trigger_error('get() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'vars\' instead.', E_USER_DEPRECATED);
if (false === $this->has($name)) {
return $default;
}
@ -122,6 +129,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function all()
{
trigger_error('all() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'vars\' instead.', E_USER_DEPRECATED);
return $this->vars;
}
@ -135,6 +144,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function getVars()
{
trigger_error('getVars() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'vars\' instead.', E_USER_DEPRECATED);
return $this->vars;
}
@ -152,6 +163,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function setAttribute($name, $value)
{
trigger_error('setAttribute() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'vars\' instead which contains an entry named "attr".', E_USER_DEPRECATED);
$this->vars['attr'][$name] = $value;
return $this;
@ -207,6 +220,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function setParent(FormView $parent = null)
{
trigger_error('setParent() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'parent\' instead.', E_USER_DEPRECATED);
$this->parent = $parent;
return $this;
@ -222,6 +237,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function getParent()
{
trigger_error('getParent() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'parent\' instead.', E_USER_DEPRECATED);
return $this->parent;
}
@ -235,6 +252,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function hasParent()
{
trigger_error('hasParent() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'parent\' instead.', E_USER_DEPRECATED);
return null !== $this->parent;
}
@ -250,6 +269,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function setChildren(array $children)
{
trigger_error('setChildren() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'children\' instead.', E_USER_DEPRECATED);
$this->children = $children;
return $this;
@ -265,6 +286,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function getChildren()
{
trigger_error('getChildren() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'children\' instead.', E_USER_DEPRECATED);
return $this->children;
}
@ -280,6 +303,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
public function getChild($name)
{
trigger_error('getChild() is deprecated since version 2.1 and will be removed in 2.3. Access the public property \'children\' instead.', E_USER_DEPRECATED);
return $this->children[$name];
}
@ -293,6 +318,8 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
*/
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;
}