[Form] Adds a way to trigger deprecation notice on demand for VirtualFormAwareIterator class.

This commit is contained in:
Hugo Hamon 2014-12-30 10:11:35 +01:00
parent 97efd2cfe5
commit a7f841e854
2 changed files with 21 additions and 2 deletions

View File

@ -25,4 +25,10 @@ namespace Symfony\Component\Form\Util;
*/
class InheritDataAwareIterator extends VirtualFormAwareIterator
{
public function __construct(\Traversable $iterator)
{
// Do not trigger deprecation notice in parent construct method
// when using this class instead of the deprecated parent one.
parent::__construct($iterator, false);
}
}

View File

@ -11,8 +11,6 @@
namespace Symfony\Component\Form\Util;
trigger_error('The '.__NAMESPACE__.'\VirtualFormAwareIterator class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Util\InheritDataAwareIterator class instead.', E_USER_DEPRECATED);
/**
* Iterator that traverses an array of forms.
*
@ -27,6 +25,21 @@ trigger_error('The '.__NAMESPACE__.'\VirtualFormAwareIterator class is deprecate
*/
class VirtualFormAwareIterator extends \IteratorIterator implements \RecursiveIterator
{
public function __construct(\Traversable $iterator, $triggerDeprecationNotice = true)
{
/**
* Prevent to trigger deprecation notice when already using the
* InheritDataAwareIterator class that extends this deprecated one.
* The {@link Symfony\Component\Form\Util\InheritDataAwareIterator::__construct} method
* forces this argument to false.
*/
if ($triggerDeprecationNotice) {
trigger_error('The '.__CLASS__.' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Form\Util\InheritDataAwareIterator class instead.', E_USER_DEPRECATED);
}
parent::__construct($iterator);
}
/**
* {@inheritdoc}
*/