Skip to content

Commit 69636bf

Browse files
committed
[Form] Deprecate TimezoneType regions option
1 parent 5f428ec commit 69636bf

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ CHANGELOG
4040
* added a cause when a CSRF error has occurred
4141
* deprecated the `scale` option of the `IntegerType`
4242
* removed restriction on allowed HTTP methods
43+
* deprecated the `regions` option of the `TimezoneType`
4344

4445
4.1.0
4546
-----

Extension/Core/Type/TimezoneType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function configureOptions(OptionsResolver $resolver)
3737
{
3838
$resolver->setDefaults(array(
3939
'choice_loader' => function (Options $options) {
40-
$regions = $options['regions'];
40+
$regions = $options->offsetGet('regions', false);
4141

4242
return new CallbackChoiceLoader(function () use ($regions) {
4343
return self::getTimezones($regions);
@@ -51,6 +51,7 @@ public function configureOptions(OptionsResolver $resolver)
5151
$resolver->setAllowedValues('input', array('string', 'datetimezone'));
5252

5353
$resolver->setAllowedTypes('regions', 'int');
54+
$resolver->setDeprecated('regions', 'The option "%name%" is deprecated since Symfony 4.2.');
5455
}
5556

5657
/**

Tests/Command/DebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testDebugDeprecatedDefaults()
4545
Built-in form types (Symfony\Component\Form\Extension\Core\Type)
4646
----------------------------------------------------------------
4747
48-
IntegerType
48+
IntegerType, TimezoneType
4949
5050
Service form types
5151
------------------

Tests/Extension/Core/Type/TimezoneTypeTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public function testDateTimeZoneInput()
5353
$this->assertEquals(array(new \DateTimeZone('Europe/Amsterdam'), new \DateTimeZone('Europe/Paris')), $form->getData());
5454
}
5555

56+
/**
57+
* @group legacy
58+
* @expectedDeprecation The option "regions" is deprecated since Symfony 4.2.
59+
*/
5660
public function testFilterByRegions()
5761
{
5862
$choices = $this->factory->create(static::TESTED_TYPE, null, array('regions' => \DateTimeZone::EUROPE))

0 commit comments

Comments
 (0)