Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbbe40d5

Browse files
committed
Remove deprecated implementation of ChoiceLoaderInterface in intl forms
1 parent9cc2a4e commitbbe40d5

File tree

8 files changed

+12
-340
lines changed

8 files changed

+12
-340
lines changed

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

Lines changed: 3 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,23 @@
1212
namespaceSymfony\Component\Form\Extension\Core\Type;
1313

1414
useSymfony\Component\Form\AbstractType;
15-
useSymfony\Component\Form\ChoiceList\ArrayChoiceList;
16-
useSymfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1715
useSymfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
1816
useSymfony\Component\Intl\Countries;
1917
useSymfony\Component\OptionsResolver\Options;
2018
useSymfony\Component\OptionsResolver\OptionsResolver;
2119

22-
class CountryTypeextends AbstractTypeimplements ChoiceLoaderInterface
20+
class CountryTypeextends AbstractType
2321
{
24-
/**
25-
* Country loaded choice list.
26-
*
27-
* The choices are lazy loaded and generated from the Intl component.
28-
*
29-
* {@link \Symfony\Component\Intl\Intl::getRegionBundle()}.
30-
*
31-
* @var ArrayChoiceList
32-
*
33-
* @deprecated since Symfony 4.1
34-
*/
35-
private$choiceList;
36-
3722
/**
3823
* {@inheritdoc}
3924
*/
4025
publicfunctionconfigureOptions(OptionsResolver$resolver)
4126
{
4227
$resolver->setDefaults([
43-
'choice_loader' =>function (Options$options) {
28+
'choice_loader' =>staticfunction (Options$options) {
4429
$choiceTranslationLocale =$options['choice_translation_locale'];
4530

46-
returnnewIntlCallbackChoiceLoader(function ()use ($choiceTranslationLocale) {
31+
returnnewIntlCallbackChoiceLoader(staticfunction ()use ($choiceTranslationLocale) {
4732
returnarray_flip(Countries::getNames($choiceTranslationLocale));
4833
});
4934
},
@@ -69,61 +54,4 @@ public function getBlockPrefix()
6954
{
7055
return'country';
7156
}
72-
73-
/**
74-
* {@inheritdoc}
75-
*
76-
* @deprecated since Symfony 4.1
77-
*/
78-
publicfunctionloadChoiceList($value =null)
79-
{
80-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.',__METHOD__),E_USER_DEPRECATED);
81-
82-
if (null !==$this->choiceList) {
83-
return$this->choiceList;
84-
}
85-
86-
return$this->choiceList =newArrayChoiceList(array_flip(Countries::getNames()),$value);
87-
}
88-
89-
/**
90-
* {@inheritdoc}
91-
*
92-
* @deprecated since Symfony 4.1
93-
*/
94-
publicfunctionloadChoicesForValues(array$values,$value =null)
95-
{
96-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.',__METHOD__),E_USER_DEPRECATED);
97-
98-
// Optimize
99-
$values =array_filter($values);
100-
if (empty($values)) {
101-
return [];
102-
}
103-
104-
return$this->loadChoiceList($value)->getChoicesForValues($values);
105-
}
106-
107-
/**
108-
* {@inheritdoc}
109-
*
110-
* @deprecated since Symfony 4.1
111-
*/
112-
publicfunctionloadValuesForChoices(array$choices,$value =null)
113-
{
114-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.',__METHOD__),E_USER_DEPRECATED);
115-
116-
// Optimize
117-
$choices =array_filter($choices);
118-
if (empty($choices)) {
119-
return [];
120-
}
121-
122-
// If no callable is set, choices are the same as values
123-
if (null ===$value) {
124-
return$choices;
125-
}
126-
127-
return$this->loadChoiceList($value)->getValuesForChoices($choices);
128-
}
12957
}

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

Lines changed: 3 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,23 @@
1212
namespaceSymfony\Component\Form\Extension\Core\Type;
1313

1414
useSymfony\Component\Form\AbstractType;
15-
useSymfony\Component\Form\ChoiceList\ArrayChoiceList;
16-
useSymfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1715
useSymfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
1816
useSymfony\Component\Intl\Currencies;
1917
useSymfony\Component\OptionsResolver\Options;
2018
useSymfony\Component\OptionsResolver\OptionsResolver;
2119

22-
class CurrencyTypeextends AbstractTypeimplements ChoiceLoaderInterface
20+
class CurrencyTypeextends AbstractType
2321
{
24-
/**
25-
* Currency loaded choice list.
26-
*
27-
* The choices are lazy loaded and generated from the Intl component.
28-
*
29-
* {@link \Symfony\Component\Intl\Intl::getCurrencyBundle()}.
30-
*
31-
* @var ArrayChoiceList
32-
*
33-
* @deprecated since Symfony 4.1
34-
*/
35-
private$choiceList;
36-
3722
/**
3823
* {@inheritdoc}
3924
*/
4025
publicfunctionconfigureOptions(OptionsResolver$resolver)
4126
{
4227
$resolver->setDefaults([
43-
'choice_loader' =>function (Options$options) {
28+
'choice_loader' =>staticfunction (Options$options) {
4429
$choiceTranslationLocale =$options['choice_translation_locale'];
4530

46-
returnnewIntlCallbackChoiceLoader(function ()use ($choiceTranslationLocale) {
31+
returnnewIntlCallbackChoiceLoader(staticfunction ()use ($choiceTranslationLocale) {
4732
returnarray_flip(Currencies::getNames($choiceTranslationLocale));
4833
});
4934
},
@@ -69,61 +54,4 @@ public function getBlockPrefix()
6954
{
7055
return'currency';
7156
}
72-
73-
/**
74-
* {@inheritdoc}
75-
*
76-
* @deprecated since Symfony 4.1
77-
*/
78-
publicfunctionloadChoiceList($value =null)
79-
{
80-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.',__METHOD__),E_USER_DEPRECATED);
81-
82-
if (null !==$this->choiceList) {
83-
return$this->choiceList;
84-
}
85-
86-
return$this->choiceList =newArrayChoiceList(array_flip(Currencies::getNames()),$value);
87-
}
88-
89-
/**
90-
* {@inheritdoc}
91-
*
92-
* @deprecated since Symfony 4.1
93-
*/
94-
publicfunctionloadChoicesForValues(array$values,$value =null)
95-
{
96-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.',__METHOD__),E_USER_DEPRECATED);
97-
98-
// Optimize
99-
$values =array_filter($values);
100-
if (empty($values)) {
101-
return [];
102-
}
103-
104-
return$this->loadChoiceList($value)->getChoicesForValues($values);
105-
}
106-
107-
/**
108-
* {@inheritdoc}
109-
*
110-
* @deprecated since Symfony 4.1
111-
*/
112-
publicfunctionloadValuesForChoices(array$choices,$value =null)
113-
{
114-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.',__METHOD__),E_USER_DEPRECATED);
115-
116-
// Optimize
117-
$choices =array_filter($choices);
118-
if (empty($choices)) {
119-
return [];
120-
}
121-
122-
// If no callable is set, choices are the same as values
123-
if (null ===$value) {
124-
return$choices;
125-
}
126-
127-
return$this->loadChoiceList($value)->getValuesForChoices($choices);
128-
}
12957
}

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

Lines changed: 3 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,23 @@
1212
namespaceSymfony\Component\Form\Extension\Core\Type;
1313

1414
useSymfony\Component\Form\AbstractType;
15-
useSymfony\Component\Form\ChoiceList\ArrayChoiceList;
16-
useSymfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
1715
useSymfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader;
1816
useSymfony\Component\Intl\Languages;
1917
useSymfony\Component\OptionsResolver\Options;
2018
useSymfony\Component\OptionsResolver\OptionsResolver;
2119

22-
class LanguageTypeextends AbstractTypeimplements ChoiceLoaderInterface
20+
class LanguageTypeextends AbstractType
2321
{
24-
/**
25-
* Language loaded choice list.
26-
*
27-
* The choices are lazy loaded and generated from the Intl component.
28-
*
29-
* {@link \Symfony\Component\Intl\Intl::getLanguageBundle()}.
30-
*
31-
* @var ArrayChoiceList
32-
*
33-
* @deprecated since Symfony 4.1
34-
*/
35-
private$choiceList;
36-
3722
/**
3823
* {@inheritdoc}
3924
*/
4025
publicfunctionconfigureOptions(OptionsResolver$resolver)
4126
{
4227
$resolver->setDefaults([
43-
'choice_loader' =>function (Options$options) {
28+
'choice_loader' =>staticfunction (Options$options) {
4429
$choiceTranslationLocale =$options['choice_translation_locale'];
4530

46-
returnnewIntlCallbackChoiceLoader(function ()use ($choiceTranslationLocale) {
31+
returnnewIntlCallbackChoiceLoader(staticfunction ()use ($choiceTranslationLocale) {
4732
returnarray_flip(Languages::getNames($choiceTranslationLocale));
4833
});
4934
},
@@ -69,61 +54,4 @@ public function getBlockPrefix()
6954
{
7055
return'language';
7156
}
72-
73-
/**
74-
* {@inheritdoc}
75-
*
76-
* @deprecated since Symfony 4.1
77-
*/
78-
publicfunctionloadChoiceList($value =null)
79-
{
80-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.',__METHOD__),E_USER_DEPRECATED);
81-
82-
if (null !==$this->choiceList) {
83-
return$this->choiceList;
84-
}
85-
86-
return$this->choiceList =newArrayChoiceList(array_flip(Languages::getNames()),$value);
87-
}
88-
89-
/**
90-
* {@inheritdoc}
91-
*
92-
* @deprecated since Symfony 4.1
93-
*/
94-
publicfunctionloadChoicesForValues(array$values,$value =null)
95-
{
96-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.',__METHOD__),E_USER_DEPRECATED);
97-
98-
// Optimize
99-
$values =array_filter($values);
100-
if (empty($values)) {
101-
return [];
102-
}
103-
104-
return$this->loadChoiceList($value)->getChoicesForValues($values);
105-
}
106-
107-
/**
108-
* {@inheritdoc}
109-
*
110-
* @deprecated since Symfony 4.1
111-
*/
112-
publicfunctionloadValuesForChoices(array$choices,$value =null)
113-
{
114-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.',__METHOD__),E_USER_DEPRECATED);
115-
116-
// Optimize
117-
$choices =array_filter($choices);
118-
if (empty($choices)) {
119-
return [];
120-
}
121-
122-
// If no callable is set, choices are the same as values
123-
if (null ===$value) {
124-
return$choices;
125-
}
126-
127-
return$this->loadChoiceList($value)->getValuesForChoices($choices);
128-
}
12957
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp