8000 [Form] Remove hard dependency on symfony/intl · symfony/symfony@f90d3ec · GitHub
[go: up one dir, main page]

Skip to content

Commit f90d3ec

Browse files
Nyholmfabpot
authored andcommitted
[Form] Remove hard dependency on symfony/intl
1 parent e872db4 commit f90d3ec

File tree

8 files changed

+30
-1
lines changed

8 files changed

+30
-1
lines changed

UPGRADE-5.3.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Form
2727
* Deprecated passing an array as the first argument of the `CheckboxListMapper::mapFormsToData()` method, pass `\Traversable` instead
2828
* Deprecated passing an array as the second argument of the `RadioListMapper::mapDataToForms()` method, pass `\Traversable` instead
2929
* Deprecated passing an array as the first argument of the `RadioListMapper::mapFormsToData()` method, pass `\Traversable` instead
30+
* Dependency on `symfony/intl` was removed. Install `symfony/intl` if you are using `LocaleType`, `CountryType`, `CurrencyType`, `LanguageType` or `TimezoneType`
3031

3132
FrameworkBundle
3233
---------------

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CHANGELOG
1414
* Deprecated passing an array as the first argument of the `RadioListMapper::mapFormsToData()` method, pass `\Traversable` instead.
1515
* Added a `choice_translation_parameters` option to `ChoiceType`
1616
* Add `UuidType` and `UlidType`
17+
* Dependency on `symfony/intl` was removed. Install `symfony/intl` if you are using `LocaleType`, `CountryType`, `CurrencyType`, `LanguageType` or `TimezoneType`.
1718

1819
5.2.0
1920
-----

src/Symfony/Component/Form/Extension/Core/Type/CountryType.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
use Symfony\Component\Form\AbstractType;
1515
use Symfony\Component\Form\ChoiceList\ChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
17+
use Symfony\Component\Form\Exception\LogicException;
1718
use Symfony\Component\Intl\Countries;
19+
use Symfony\Component\Intl\Intl;
1820
use Symfony\Component\OptionsResolver\Options;
1921
use Symfony\Component\OptionsResolver\OptionsResolver;
2022

@@ -27,6 +29,10 @@ public function configureOptions(OptionsResolver $resolver)
2729
{
2830
$resolver->setDefaults([
2931
'choice_loader' => function (Options $options) {
32+
if (!class_exists(Intl::class)) {
33+
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s". Try running "composer require symfony/intl".', static::class));
34+
}
35+
3036
$choiceTranslationLocale = $options['choice_translation_locale'];
3137
$alpha3 = $options['alpha3'];
3238

src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
use Symfony\Component\Form\AbstractType;
1515
use Symfony\Component\Form\ChoiceList\ChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
17+
use Symfony\Component\Form\Exception\LogicException;
1718
use Symfony\Component\Intl\Currencies;
19+
use Symfony\Component\Intl\Intl;
1820
use Symfony\Component\OptionsResolver\Options;
1921
use Symfony\Component\OptionsResolver\OptionsResolver;
2022

@@ -27,6 +29,10 @@ public function configureOptions(OptionsResolver $resolver)
2729
{
2830
$resolver->setDefaults([
2931
'choice_loader' => function (Options $options) {
32+
if (!class_exists(Intl::class)) {
33+
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s". Try running "composer require symfony/intl".', static::class));
34+
}
35+
3036
$choiceTranslationLocale = $options['choice_translation_locale'];
3137

3238
return ChoiceList::loader($this, new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
1717
use Symfony\Component\Form\Exception\LogicException;
1818
use Symfony\Component\Intl\Exception\MissingResourceException;
19+
use Symfony\Component\Intl\Intl;
1920
use Symfony\Component\Intl\Languages;
2021
use Symfony\Component\OptionsResolver\Options;
2122
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -29,6 +30,9 @@ public function configureOptions(OptionsResolver $resolver)
2930
{
3031
$resolver->setDefaults([
3132
'choice_loader' => function (Options $options) {
33+
if (!class_exists(Intl::class)) {
34+
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s". Try running "composer require symfony/intl".', static::class));
35+
}
3236
$choiceTranslationLocale = $options['choice_translation_locale'];
3337
$useAlpha3Codes = $options['alpha3'];
3438
$choiceSelfTranslation = $options['choice_self_translation'];

src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Symfony\Component\Form\AbstractType;
1515
use Symfony\Component\Form\ChoiceList\ChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
17+
use Symfony\Component\Form\Exception\LogicException;
18+
use Symfony\Component\Intl\Intl;
1719
use Symfony\Component\Intl\Locales;
1820
use Symfony\Component\OptionsResolver\Options;
1921
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -27,6 +29,10 @@ public function configureOptions(OptionsResolver $resolver)
2729
{
2830
$resolver->setDefaults([
2931
'choice_loader' => function (Options $options) {
32+
if (!class_exists(Intl::class)) {
33+
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s". Try running "composer require symfony/intl".', static::class));
34+
}
35+
3036
$choiceTranslationLocale = $options['choice_translation_locale'];
3137

3238
return ChoiceList::loader($this, new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeZoneToStringTransformer;
1919
use Symfony\Component\Form\Extension\Core\DataTransformer\IntlTimeZoneToStringTransformer;
2020
use Symfony\Component\Form\FormBuilderInterface;
21+
use Symfony\Component\Intl\Intl;
2122
use Symfony\Component\Intl\Timezones;
2223
use Symfony\Component\OptionsResolver\Options;
2324
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -47,6 +48,10 @@ public function configureOptions(OptionsResolver $resolver)
4748
$input = $options['input'];
4849

4950
if ($options['intl']) {
51+
if (!class_exists(Intl::class)) {
52+
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s" with option "intl=true". Try running "composer require symfony/intl".', static::class));
53+
}
54+
5055
$choiceTranslationLocale = $options['choice_translation_locale'];
5156

5257
return ChoiceList::loader($this, new IntlCallbackChoiceLoader(function () use ($input, $choiceTranslationLocale) {
BB33

src/Symfony/Component/Form/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"php": ">=7.2.5",
2020
"symfony/deprecation-contracts": "^2.1",
2121
"symfony/event-dispatcher": "^4.4|^5.0",
22-
"symfony/intl": "^4.4|^5.0",
2322
"symfony/options-resolver": "^5.1",
2423
"symfony/polyfill-ctype": "~1.8",
2524
"symfony/polyfill-intl-icu": "^1.21",
@@ -37,6 +36,7 @@
3736
"symfony/console": "^4.4|^5.0",
3837
"symfony/http-foundation": "^4.4|^5.0",
3938
"symfony/http-kernel": "^4.4|^5.0",
39+
"symfony/intl": "^4.4|^5.0",
4040
"symfony/security-csrf": "^4.4|^5.0",
4141
"symfony/translation": "^4.4|^5.0",
4242
"symfony/var-dumper": "^4.4|^5.0",

0 commit comments

Comments
 (0)
0