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
-------
73c688c967
[Form] Check for Intl availibility
This commit is contained in:
commit
15aa25a1ed
@ -15,6 +15,7 @@ use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
|
||||
use Symfony\Component\Form\Exception\LogicException;
|
||||
use Symfony\Component\Intl\Intl;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
@ -41,6 +42,10 @@ class CountryType extends AbstractType implements ChoiceLoaderInterface
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'choice_loader' => function (Options $options) {
|
||||
if (!class_exists(Intl::class)) {
|
||||
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
|
||||
}
|
||||
|
||||
$choiceTranslationLocale = $options['choice_translation_locale'];
|
||||
|
||||
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
|
||||
use Symfony\Component\Form\Exception\LogicException;
|
||||
use Symfony\Component\Intl\Intl;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
@ -41,6 +42,10 @@ class CurrencyType extends AbstractType implements ChoiceLoaderInterface
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'choice_loader' => function (Options $options) {
|
||||
if (!class_exists(Intl::class)) {
|
||||
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
|
||||
}
|
||||
|
||||
$choiceTranslationLocale = $options['choice_translation_locale'];
|
||||
|
||||
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
|
||||
use Symfony\Component\Form\Exception\LogicException;
|
||||
use Symfony\Component\Intl\Intl;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
@ -41,6 +42,10 @@ class LanguageType extends AbstractType implements ChoiceLoaderInterface
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'choice_loader' => function (Options $options) {
|
||||
if (!class_exists(Intl::class)) {
|
||||
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
|
||||
}
|
||||
|
||||
$choiceTranslationLocale = $options['choice_translation_locale'];
|
||||
|
||||
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {
|
||||
|
@ -15,6 +15,7 @@ use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
|
||||
use Symfony\Component\Form\Exception\LogicException;
|
||||
use Symfony\Component\Intl\Intl;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
@ -41,6 +42,10 @@ class LocaleType extends AbstractType implements ChoiceLoaderInterface
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'choice_loader' => function (Options $options) {
|
||||
if (!class_exists(Intl::class)) {
|
||||
throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s".', static::class));
|
||||
}
|
||||
|
||||
$choiceTranslationLocale = $options['choice_translation_locale'];
|
||||
|
||||
return new IntlCallbackChoiceLoader(function () use ($choiceTranslationLocale) {
|
||||
|
Reference in New Issue
Block a user