Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d80fd74

Browse filesBrowse files
committed
feature #13407 [Form] Remove deprecated setDefaultOptions and OptionsResolverInterface (peterrehm)
This PR was merged into the 3.0-dev branch. Discussion ---------- [Form] Remove deprecated setDefaultOptions and OptionsResolverInterface | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | symfony/symfony-docs#4786 | Related | #12891 Commits ------- 9b9158b Remove the deprecated OptionsResolverInterface 6026781 Removed deprecated setDefaultOptions methods
2 parents 8845042 + 88ad3cf commit d80fd74
Copy full SHA for d80fd74
Expand file treeCollapse file tree

7 files changed

+15
-58
lines changed

‎AbstractType.php

Copy file name to clipboardExpand all lines: AbstractType.php
-11Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Form;
1313

1414
use Symfony\Component\OptionsResolver\OptionsResolver;
15-
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
1615

1716
/**
1817
* @author Bernhard Schussek <bschussek@gmail.com>
@@ -43,16 +42,6 @@ public function finishView(FormView $view, FormInterface $form, array $options)
4342
/**
4443
* {@inheritdoc}
4544
*/
46-
public function setDefaultOptions(OptionsResolverInterface $resolver)
47-
{
48-
$this->configureOptions($resolver);
49-
}
50-
51-
/**
52-
* Configures the options for this type.
53-
*
54-
* @param OptionsResolver $resolver The resolver for the options.
55-
*/
5645
public function configureOptions(OptionsResolver $resolver)
5746
{
5847
}

‎AbstractTypeExtension.php

Copy file name to clipboardExpand all lines: AbstractTypeExtension.php
-11Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Form;
1313

1414
use Symfony\Component\OptionsResolver\OptionsResolver;
15-
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
1615

1716
/**
1817
* @author Bernhard Schussek <bschussek@gmail.com>
@@ -43,16 +42,6 @@ public function finishView(FormView $view, FormInterface $form, array $options)
4342
/**
4443
* {@inheritdoc}
4544
*/
46-
public function setDefaultOptions(OptionsResolverInterface $resolver)
47-
{
48-
$this->configureOptions($resolver);
49-
}
50-
51-
/**
52-
* Configures the options for this type.
53-
*
54-
* @param OptionsResolver $resolver The resolver for the options.
55-
*/
5645
public function configureOptions(OptionsResolver $resolver)
5746
{
5847
}

‎FormTypeExtensionInterface.php

Copy file name to clipboardExpand all lines: FormTypeExtensionInterface.php
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Form;
1313

14-
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
14+
use Symfony\Component\OptionsResolver\OptionsResolver;
1515

1616
/**
1717
* @author Bernhard Schussek <bschussek@gmail.com>
@@ -60,15 +60,12 @@ public function buildView(FormView $view, FormInterface $form, array $options);
6060
public function finishView(FormView $view, FormInterface $form, array $options);
6161

6262
/**
63-
* Overrides the default options from the extended type.
63+
* Configures the options for this type.
6464
*
65-
* @param OptionsResolverInterface $resolver The resolver for the options.
65+
* @param OptionsResolver $resolver The resolver for the options.
6666
*
67-
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
68-
* Use the method configureOptions instead. This method will be
69-
* added to the FormTypeExtensionInterface with Symfony 3.0
7067
*/
71-
public function setDefaultOptions(OptionsResolverInterface $resolver);
68+
public function configureOptions(OptionsResolver $resolver);
7269

7370
/**
7471
* Returns the name of the type being extended.

‎FormTypeInterface.php

Copy file name to clipboardExpand all lines: FormTypeInterface.php
+4-8Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Form;
1313

14-
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
14+
use Symfony\Component\OptionsResolver\OptionsResolver;
1515

1616
/**
1717
* @author Bernhard Schussek <bschussek@gmail.com>
@@ -69,15 +69,11 @@ public function buildView(FormView $view, FormInterface $form, array $options);
6969
public function finishView(FormView $view, FormInterface $form, array $options);
7070

7171
/**
72-
* Sets the default options for this type.
72+
* Configures the options for this type.
7373
*
74-
* @param OptionsResolverInterface $resolver The resolver for the options.
75-
*
76-
* @deprecated Deprecated since Symfony 2.7, to be renamed in Symfony 3.0.
77-
* Use the method configureOptions instead. This method will be
78-
* added to the FormTypeInterface with Symfony 3.0.
74+
* @param OptionsResolver $resolver The resolver for the options.
7975
*/
80-
public function setDefaultOptions(OptionsResolverInterface $resolver);
76+
public function configureOptions(OptionsResolver $resolver);
8177

8278
/**
8379
* Returns the name of the parent type.

‎ResolvedFormType.php

Copy file name to clipboardExpand all lines: ResolvedFormType.php
+3-17Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function finishView(FormView $view, FormInterface $form, array $options)
192192
/**
193193
* Returns the configured options resolver used for this type.
194194
*
195-
* @return \Symfony\Component\OptionsResolver\OptionsResolverInterface The options resolver.
195+
* @return \Symfony\Component\OptionsResolver\OptionsResolver The options resolver.
196196
*/
197197
public function getOptionsResolver()
198198
{
@@ -203,24 +203,10 @@ public function getOptionsResolver()
203203
$this->optionsResolver = new OptionsResolver();
204204
}
205205

206-
$this->innerType->setDefaultOptions($this->optionsResolver);
207-
208-
$reflector = new \ReflectionMethod($this->innerType, 'setDefaultOptions');
209-
$isOverwritten = ($reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType');
210-
211-
if (true === $isOverwritten) {
212-
trigger_error('The FormTypeInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeInterface with Symfony 3.0.', E_USER_DEPRECATED);
213-
}
206+
$this->innerType->configureOptions($this->optionsResolver);
214207

215208
foreach ($this->typeExtensions as $extension) {
216-
$extension->setDefaultOptions($this->optionsResolver);
217-
218-
$reflector = new \ReflectionMethod($extension, 'setDefaultOptions');
219-
$isOverwritten = ($reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension');
220-
221-
if (true === $isOverwritten) {
222-
trigger_error('The FormTypeExtensionInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeExtensionInterface with Symfony 3.0.', E_USER_DEPRECATED);
223-
}
209+
$extension->configureOptions($this->optionsResolver);
224210
}
225211
}
226212

‎ResolvedFormTypeInterface.php

Copy file name to clipboardExpand all lines: ResolvedFormTypeInterface.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Form;
1313

14-
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
14+
use Symfony\Component\OptionsResolver\OptionsResolver;
1515

1616
/**
1717
* A wrapper for a form type and its extensions.
@@ -102,7 +102,7 @@ public function finishView(FormView $view, FormInterface $form, array $options);
102102
/**
103103
* Returns the configured options resolver used for this type.
104104
*
105-
* @return OptionsResolverInterface The options resolver.
105+
* @return OptionsResolver The options resolver.
106106
*/
107107
public function getOptionsResolver();
108108
}

‎Tests/ResolvedFormTypeTest.php

Copy file name to clipboardExpand all lines: Tests/ResolvedFormTypeTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function testCreateBuilder()
9999
{
100100
$givenOptions = array('a' => 'a_custom', 'c' => 'c_custom');
101101
$resolvedOptions = array('a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default');
102-
$optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolverInterface');
102+
$optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolver');
103103

104104
$this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType')
105105
->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType))
@@ -127,7 +127,7 @@ public function testCreateBuilderWithDataClassOption()
127127
{
128128
$givenOptions = array('data_class' => 'Foo');
129129
$resolvedOptions = array('data_class' => '\stdClass');
130-
$optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolverInterface');
130+
$optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolver');
131131

132132
$this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType')
133133
->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.