Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b01ea27

Browse files
committed
feature #28860 [Form] Deprecate TimezoneType regions option (ro0NL)
This PR was merged into the 4.2-dev branch. Discussion ---------- [Form] Deprecate TimezoneType regions option | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | yes | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #28848 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> I know i've added this option myself in 4.1, but given my recent development for #28624 i realized it's an opinionated feaure, which can/should be solved on user-side (`choice_filter/choice_loader` and/or `group_by`). - blocks translations as we dont have them (see #28831) - blocks possibility of switching to Intl zones which doesnt really have this filter feature (see #28836) ~While at it, i solved a few issues with `OptionsResolver` that is able to deprecate options as of 4.2 also.~ Fixed in #28878 - when resolved trigger the deprecation - allow to opt-out from triggering the deprecation - dont trigger deprecation for default values (only given ones) Commits ------- 5cb532d [Form] Deprecate TimezoneType regions option
2 parents 5ae0e89 + 5cb532d commit b01ea27

File tree

6 files changed

+12
-2
lines changed

6 files changed

+12
-2
lines changed

UPGRADE-4.2.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ Form
104104
{% endfor %}
105105
```
106106

107+
* The `regions` option of the `TimezoneType` is deprecated.
108+
107109
HttpFoundation
108110
--------------
109111

UPGRADE-5.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ Form
121121
{% endfor %}
122122
```
123123

124+
* The `regions` option was removed from the `TimezoneType`.
125+
124126
FrameworkBundle
125127
---------------
126128

src/Symfony/Component/Form/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
-----

src/Symfony/Component/Form/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
/**

src/Symfony/Component/Form/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
------------------

src/Symfony/Component/Form/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)