8000 minor #28610 [Form] Check for Intl availibility (ro0NL) · symfony/symfony@15aa25a · GitHub
[go: up one dir, main page]

Skip to content

Commit 15aa25a

Browse files
committed
minor #28610 [Form] Check for Intl availibility (ro0NL)
This PR was merged into the 4.2-dev branch. Discussion ---------- [Form] Check for Intl availibility | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Same as #28513 for the form component Commits ------- 73c688c [Form] Check for Intl availibility
2 parents 3cd411a + 73c688c commit 15aa25a

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18+
use Symfony\Component\Form\Exception\LogicException;
1819
use Symfony\Component\Intl\Intl;
1920
use Symfony\Component\OptionsResolver\Options;
2021
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -41,6 +42,10 @@ public function configureOptions(OptionsResolver $resolver)
4142
{
4243
$resolver->setDefaults(array(
4344
'choice_loader' => function (Options $options) {
45+
if (!class_exists(Intl::class)) {
46+
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47+
}
48+
4449
$choiceTranslationLocale = $options['choice_translation_locale'];
4550

4651
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18+
use Symfony\Component\Form\Exception\LogicException;
1819
use Symfony\Component\Intl\Intl;
1920
use Symfony\Component\OptionsResolver\Options;
2021
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -41,6 +42,10 @@ public function configureOptions(OptionsResolver $resolver)
4142
{
4243
$resolver->setDefaults(array(
4344
'choice_loader' => function (Options $options) {
45+
if (!class_exists(Intl::class)) {
46+
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47+
}
48+
4449
$choiceTranslationLocale = $options['choice_translation_locale'];
4550

4651
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18+
use Symfony\Component\Form\Exception\LogicException;
1819
use Symfony\Component\Intl\Intl;
1920
use Symfony\Component\OptionsResolver\Options;
2021
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -41,6 +42,10 @@ public function configureOptions(OptionsResolver $resolver)
4142
{
4243
$resolver->setDefaults(array(
4344
'choice_loader' => function (Options $options) {
45+
if (!class_exists(Intl::class)) {
46+
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47+
}
48+
4449
$choiceTranslationLocale = $options['choice_translation_locale'];
4550

4651
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
1616
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1717
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
18+
use Symfony\Component\Form\Exception\LogicException;
1819
use Symfony\Component\Intl\Intl;
1920
use Symfony\Component\OptionsResolver\Options;
2021
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -41,6 +42,10 @@ public function configureOptions(OptionsResolver $resolver)
4142
{
4243
$resolver->setDefaults(array(
4344
'choice_loader' => function (Options $options) {
45+
if (!class_exists(Intl::class)) {
46+
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
47+
}
48+
4449
$choiceTranslationLocale = $options['choice_translation_locale'];
4550

4651
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {

0 commit comments

Comments
 (0)
0