Skip to content

Commit

Permalink
Removed deprecated setDefaultOptions methods
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrehm committed Jan 20, 2015
1 parent db80498 commit 6026781
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 56 deletions.
11 changes: 0 additions & 11 deletions src/Symfony/Component/Form/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\Form;

use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
* @author Bernhard Schussek <bschussek@gmail.com>
Expand Down Expand Up @@ -43,16 +42,6 @@ public function finishView(FormView $view, FormInterface $form, array $options)
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$this->configureOptions($resolver);
}

/**
* Configures the options for this type.
*
* @param OptionsResolver $resolver The resolver for the options.
*/
public function configureOptions(OptionsResolver $resolver)
{
}
Expand Down
11 changes: 0 additions & 11 deletions src/Symfony/Component/Form/AbstractTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\Form;

use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

/**
* @author Bernhard Schussek <bschussek@gmail.com>
Expand Down Expand Up @@ -43,16 +42,6 @@ public function finishView(FormView $view, FormInterface $form, array $options)
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$this->configureOptions($resolver);
}

/**
* Configures the options for this type.
*
* @param OptionsResolver $resolver The resolver for the options.
*/
public function configureOptions(OptionsResolver $resolver)
{
}
Expand Down
11 changes: 4 additions & 7 deletions src/Symfony/Component/Form/FormTypeExtensionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Form;

use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

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

/**
* Overrides the default options from the extended type.
* Configures the options for this type.
*
* @param OptionsResolverInterface $resolver The resolver for the options.
* @param OptionsResolver $resolver The resolver for the options.
*
* @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0.
* Use the method configureOptions instead. This method will be
* added to the FormTypeExtensionInterface with Symfony 3.0
*/
public function setDefaultOptions(OptionsResolverInterface $resolver);
public function configureOptions(OptionsResolver $resolver);

/**
* Returns the name of the type being extended.
Expand Down
12 changes: 4 additions & 8 deletions src/Symfony/Component/Form/FormTypeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Form;

use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

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

/**
* Sets the default options for this type.
* Configures the options for this type.
*
* @param OptionsResolverInterface $resolver The resolver for the options.
*
* @deprecated Deprecated since Symfony 2.7, to be renamed in Symfony 3.0.
* Use the method configureOptions instead. This method will be
* added to the FormTypeInterface with Symfony 3.0.
* @param OptionsResolver $resolver The resolver for the options.
*/
public function setDefaultOptions(OptionsResolverInterface $resolver);
public function configureOptions(OptionsResolver $resolver);

/**
* Returns the name of the parent type.
Expand Down
20 changes: 3 additions & 17 deletions src/Symfony/Component/Form/ResolvedFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function finishView(FormView $view, FormInterface $form, array $options)
/**
* Returns the configured options resolver used for this type.
*
* @return \Symfony\Component\OptionsResolver\OptionsResolverInterface The options resolver.
* @return \Symfony\Component\OptionsResolver\OptionsResolver The options resolver.
*/
public function getOptionsResolver()
{
Expand All @@ -203,24 +203,10 @@ public function getOptionsResolver()
$this->optionsResolver = new OptionsResolver();
}

$this->innerType->setDefaultOptions($this->optionsResolver);

$reflector = new \ReflectionMethod($this->innerType, 'setDefaultOptions');
$isOverwritten = ($reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType');

if (true === $isOverwritten) {
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);
}
$this->innerType->configureOptions($this->optionsResolver);

foreach ($this->typeExtensions as $extension) {
$extension->setDefaultOptions($this->optionsResolver);

$reflector = new \ReflectionMethod($extension, 'setDefaultOptions');
$isOverwritten = ($reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension');

if (true === $isOverwritten) {
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);
}
$extension->configureOptions($this->optionsResolver);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function testCreateBuilder()
{
$givenOptions = array('a' => 'a_custom', 'c' => 'c_custom');
$resolvedOptions = array('a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default');
$optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolverInterface');
$optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolver');

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

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

0 comments on commit 6026781

Please sign in to comment.