[Form] Deprecate TimezoneType regions option

This commit is contained in:
Roland Franssen 2018-10-14 14:03:53 +02:00
parent a6e4d4abef
commit 5cb532d2de
6 changed files with 12 additions and 2 deletions

View File

@ -104,6 +104,8 @@ Form
{% endfor %}
```
* The `regions` option of the `TimezoneType` is deprecated.
HttpFoundation
--------------

View File

@ -121,6 +121,8 @@ Form
{% endfor %}
```
* The `regions` option was removed from the `TimezoneType`.
FrameworkBundle
---------------

View File

@ -40,6 +40,7 @@ CHANGELOG
* added a cause when a CSRF error has occurred
* deprecated the `scale` option of the `IntegerType`
* removed restriction on allowed HTTP methods
* deprecated the `regions` option of the `TimezoneType`
4.1.0
-----

View File

@ -37,7 +37,7 @@ class TimezoneType extends AbstractType
{
$resolver->setDefaults(array(
'choice_loader' => function (Options $options) {
$regions = $options['regions'];
$regions = $options->offsetGet('regions', false);
return new CallbackChoiceLoader(function () use ($regions) {
return self::getTimezones($regions);
@ -51,6 +51,7 @@ class TimezoneType extends AbstractType
$resolver->setAllowedValues('input', array('string', 'datetimezone'));
$resolver->setAllowedTypes('regions', 'int');
$resolver->setDeprecated('regions', 'The option "%name%" is deprecated since Symfony 4.2.');
}
/**

View File

@ -45,7 +45,7 @@ class DebugCommandTest extends TestCase
Built-in form types (Symfony\Component\Form\Extension\Core\Type)
----------------------------------------------------------------
IntegerType
IntegerType, TimezoneType
Service form types
------------------

View File

@ -53,6 +53,10 @@ class TimezoneTypeTest extends BaseTypeTest
$this->assertEquals(array(new \DateTimeZone('Europe/Amsterdam'), new \DateTimeZone('Europe/Paris')), $form->getData());
}
/**
* @group legacy
* @expectedDeprecation The option "regions" is deprecated since Symfony 4.2.
*/
public function testFilterByRegions()
{
$choices = $this->factory->create(static::TESTED_TYPE, null, array('regions' => \DateTimeZone::EUROPE))