From c21b12e896556d7e1aa3d33d218f7adc626f1cbd Mon Sep 17 00:00:00 2001 From: Colin Frei Date: Fri, 14 Dec 2012 07:33:36 +0100 Subject: [PATCH] [Form] handle BC use of deprecated stuff in non-test-methods. --- src/Symfony/Component/Form/Form.php | 8 ++++++++ src/Symfony/Component/Form/FormFactory.php | 2 ++ src/Symfony/Component/Form/FormRegistry.php | 2 ++ 3 files changed, 12 insertions(+) diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index ed6cea4e00..4d363b3e3b 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -366,7 +366,9 @@ class Form implements \IteratorAggregate, FormInterface // Hook to change content of the data if ($dispatcher->hasListeners(FormEvents::PRE_SET_DATA) || $dispatcher->hasListeners(FormEvents::SET_DATA)) { + set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC')); $event = new FormEvent($this, $modelData); + restore_error_handler(); $dispatcher->dispatch(FormEvents::PRE_SET_DATA, $event); // BC until 2.3 $dispatcher->dispatch(FormEvents::SET_DATA, $event); @@ -529,7 +531,9 @@ class Form implements \IteratorAggregate, FormInterface // Hook to change content of the data bound by the browser if ($dispatcher->hasListeners(FormEvents::PRE_BIND) || $dispatcher->hasListeners(FormEvents::BIND_CLIENT_DATA)) { + set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC')); $event = new FormEvent($this, $submittedData); + restore_error_handler(); $dispatcher->dispatch(FormEvents::PRE_BIND, $event); // BC until 2.3 $dispatcher->dispatch(FormEvents::BIND_CLIENT_DATA, $event); @@ -589,7 +593,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)) { + set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC')); $event = new FormEvent($this, $normData); + restore_error_handler(); $dispatcher->dispatch(FormEvents::BIND, $event); // BC until 2.3 $dispatcher->dispatch(FormEvents::BIND_NORM_DATA, $event); @@ -613,9 +619,11 @@ class Form implements \IteratorAggregate, FormInterface $dispatcher->dispatch(FormEvents::POST_BIND, $event); } + set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC')); foreach ($this->config->getValidators() as $validator) { $validator->validate($this); } + restore_error_handler(); return $this; } diff --git a/src/Symfony/Component/Form/FormFactory.php b/src/Symfony/Component/Form/FormFactory.php index ce60e7d42f..a5d8053724 100644 --- a/src/Symfony/Component/Form/FormFactory.php +++ b/src/Symfony/Component/Form/FormFactory.php @@ -99,7 +99,9 @@ class FormFactory implements FormFactoryInterface $typeGuess = $guesser->guessType($class, $property); $maxLengthGuess = $guesser->guessMaxLength($class, $property); // Keep $minLengthGuess for BC until Symfony 2.3 + set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC')); $minLengthGuess = $guesser->guessMinLength($class, $property); + restore_error_handler(); $requiredGuess = $guesser->guessRequired($class, $property); $patternGuess = $guesser->guessPattern($class, $property); diff --git a/src/Symfony/Component/Form/FormRegistry.php b/src/Symfony/Component/Form/FormRegistry.php index 24df9a8053..39a3f6befe 100644 --- a/src/Symfony/Component/Form/FormRegistry.php +++ b/src/Symfony/Component/Form/FormRegistry.php @@ -131,11 +131,13 @@ class FormRegistry implements FormRegistryInterface ); } + set_error_handler(array('Symfony\Component\Form\Tests\DeprecationErrorHandler', 'handleBC')); $this->addType($this->resolvedTypeFactory->createResolvedType( $type, $typeExtensions, $parentType ? $this->getType($parentType) : null )); + restore_error_handler(); } /**