8000 [Form] Fixed the deprecation notes for the "virtual" option · symfony/symfony@1290b80 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1290b80

Browse files
committed
[Form] Fixed the deprecation notes for the "virtual" option
1 parent ac2ca44 commit 1290b80

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CHANGELOG
99
* added FormProcessorInterface and FormInterface::process()
1010
* deprecated passing a Request instance to FormInterface::bind()
1111
* added options "method" and "action" to FormType
12-
* deprecated option "virtual", renamed it to "inherit_data"
12+
* deprecated option "virtual" in favor "inherit_data"
1313
* deprecated VirtualFormAwareIterator in favor of InheritDataAwareIterator
1414
* [BC BREAK] removed the "array" type hint from DataMapperInterface
1515
* improved forms inheriting their parent data to actually return that data from getData(), getNormData() and getViewData()

src/Symfony/Component/Form/Extension/Core/Type/FormType.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
150150
return $options['compound'];
151151
};
152152

153+
// BC with old "virtual" option
154+
$inheritData = function (Options $options) {
155+
if (null !== $options['virtual']) {
156+
// Uncomment this as soon as the deprecation note should be shown
157+
// trigger_error('The form option "virtual" is deprecated since version 2.3 and will be removed in 3.0. Use "inherit_data" instead.', E_USER_DEPRECATED);
158+
159+
return $options['virtual'];
160+
}
161+
162+
return false;
163+
};
164+
153165
// If data is given, the form is locked to that data
154166
// (independent of its value)
155167
$resolver->setOptional(array(
@@ -169,7 +181,8 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
169181
'by_reference' => true,
170182
'error_bubbling' => $errorBubbling,
171183
'label_attr' => array(),
172-
'inherit_data' => false,
184+
'virtual' => null,
185+
'inherit_data' => $inheritData,
173186
'compound' => true,
174187
'method' => 'POST',
175188
// According to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt)

src/Symfony/Component/Form/FormConfigBuilder.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,13 @@ public function getInheritData()
351351
*
352352
* @return FormConfigBuilder The configuration object.
353353
*
354-
* @deprecated Deprecated since version 2.2, to be removed in 2.3. Use
354+
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
355355
* {@link getInheritData()} instead.
356356
*/
357357
public function getVirtual()
358358
{
359-
trigger_error('getVirtual() is deprecated since version 2.2 and will be removed in 2.3. Use getInheritData() instead.', E_USER_DEPRECATED);
359+
// Uncomment this as soon as the deprecation note should be shown
360+
// trigger_error('getVirtual() is deprecated since version 2.3 and will be removed in 3.0. Use getInheritData() instead.', E_USER_DEPRECATED);
360361

361362
return $this->getInheritData();
362363
}
@@ -709,12 +710,13 @@ public function setInheritData($inheritData)
709710
*
710711
* @return FormConfigBuilder The configuration object.
711712
*
712-
* @deprecated Deprecated since version 2.2, to be removed in 2.3. Use
713+
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
713714
* {@link setInheritData()} instead.
714715
*/
715716
public function setVirtual($inheritData)
716717
{
717-
trigger_error('setVirtual() is deprecated since version 2.2 and will be removed in 2.3. Use setInheritData() instead.', E_USER_DEPRECATED);
718+
// Uncomment this as soon as the deprecation note should be shown
719+
// trigger_error('setVirtual() is deprecated since version 2.3 and will be removed in 3.0. Use setInheritData() instead.', E_USER_DEPRECATED);
718720

719721
$this->setInheritData($inheritData);
720722
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author Bernhard Schussek <bschussek@gmail.com>
2222
*
23-
* @deprecated Deprecated since version 2.2, to be removed in 2.3. Use
23+
* @deprecated Deprecated since version 2.3, to be removed in 3.0. Use
2424
* {@link InheritDataAwareIterator} instead.
2525
*/
2626
class VirtualFormAwareIterator extends \ArrayIterator implements \RecursiveIterator
@@ -32,7 +32,8 @@ class VirtualFormAwareIterator extends \ArrayIterator implements \RecursiveItera
3232
*/
3333
public function __construct(array $forms)
3434
{
35-
trigger_error('VirtualFormAwareIterator is deprecated since version 2.2 and will be removed in 2.3. Use InheritDataAwareIterator instead.', E_USER_DEPRECATED);
35+
// Uncomment this as soon as the deprecation note should be shown
36+
// trigger_error('VirtualFormAwareIterator is deprecated since version 2.3 and will be removed in 3.0. Use InheritDataAwareIterator instead.', E_USER_DEPRECATED);
3637

3738
parent::__construct($forms);
3839
}

0 commit comments

Comments
 (0)
0