8000 [Form] Adds a way to trigger deprecation notice on demand for Virtual… · symfony/symfony@a7f841e · GitHub
[go: up one dir, main page]

Skip to content

Commit a7f841e

Browse files
author
Hugo Hamon
committed
[Form] Adds a way to trigger deprecation notice on demand for VirtualFormAwareIterator class.
1 parent 97efd2c commit a7f841e

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/Symfony/Component/Form/Util/InheritDataAwareIterator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,10 @@
2525
*/
2626
class InheritDataAwareIterator extends VirtualFormAwareIterator
2727
{
28+
public function __construct(\Traversable $iterator)
29+
{
30+
// Do not trigger deprecation notice in parent construct method
31+
// when using this class instead of the deprecated parent one.
32+
parent::__construct($iterator, false);
33+
}
2834
}

src/Symfony/Component/Form/Util/VirtualFormAwareIterator.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Form\Util;
1313

14-
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);
15-
1614
/**
1715
* Iterator that traverses an array of forms.
1816
*
@@ -27,6 +25,21 @@
2725
*/
2826
class VirtualFormAwareIterator extends \IteratorIterator implements \RecursiveIterator
2927
{
28+
public function __construct(\Traversable $iterator, $triggerDeprecationNotice = true)
29+
{
30+
/**
31+
* Prevent to trigger deprecation notice when already using the
32+
* InheritDataAwareIterator class that extends this deprecated one.
33+
* The {@link Symfony\Component\Form\Util\InheritDataAwareIterator::__construct} method
34+
* forces this argument to false.
35+
*/
36+
if ($triggerDeprecationNotice) {
37+
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);
38+
}
39+
40+
parent::__construct($iterator);
41+
}
42+
3043
/**
3144
* {@inheritdoc}
3245
*/

0 commit comments

Comments
 (0)
0