-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Add choice_translation_locale option for Intl choice types #26825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c81bf25
to
b26715f
Compare
b26715f
to
1480bbd
Compare
// BC layer | ||
$self = clone $this; | ||
$self->choiceLoader = $choiceLoader; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of deprecating each ChoiceLoaderInterface
methods (trigerring a lot of messages) shouldn't be enough just one here? deprecating the usage of this form type as choice loader? wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we always return the new loader here and just add deprecations to the ChoiceLoaderInterface
's methods without modifying them? We indeed target to remove the ChoiceLoaderInterface
from all of these types, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmh.. I guess that was what we did in https://github.com/symfony/symfony/pull/23648/files#diff-c6198934d4f35bc102ff362d40b71285R61, but isn't it a BC break?
I mean, if we return the new loader now then, we're ignoring any custom behavior for someone overriding loadChoiceList()
method without previous advice, no? ping @ro0NL ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's a pragmatic choice; switching an implementation detail. Technically no API was broken 😅
Maybe to overcome preserve the legacy loader somehow, like return new CallbackLegacyChoiceLoader($callable, $this)
.
we're ignoring any custom behavior for someone overriding loadChoiceList()
Im really not sure how big an issue this is, in practice. In theory you're right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That way you can check if a API method is overridden on the legacy loader and deprecate from there, while keep calling it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @ro0NL. Not sure it is worth it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, in that case I prefer @ro0NL's version, I did the changes, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this @yceruto :)
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class CountryType extends AbstractType implements ChoiceLoaderInterface | ||
{ | ||
/** | ||
* Country loaded choice list. | ||
* BC layer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By marking it @deprecated
instead, even if it's private, would help a bit when reading these classes from an IDE as the property usages in this class will be striked out.
// BC layer | ||
$self = clone $this; | ||
$self->choiceLoader = $choiceLoader; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we always return the new loader here and just add deprecations to the ChoiceLoaderInterface
's methods without modifying them? We indeed target to remove the ChoiceLoaderInterface
from all of these types, right?
b4c0658
to
59d4d00
Compare
@ogizanagi thank you for this review. Status: Waiting consensus on depreciation path :) |
Status: Needs Review |
bbc7834
to
a69b31f
Compare
a69b31f
to
a4797ac
Compare
Just squashing commits, ready on my side. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small CS change needed
*/ | ||
public function loadChoiceList($value = null) | ||
{ | ||
@trigger_error(sprintf('Method "%s" is deprecated since Symfony 4.2. Use "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer one sentence for deprecations: ... since Symfony 4.2, use ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
UPGRADE-4.2.md
Outdated
Form | ||
---- | ||
|
||
* Deprecated `ChoiceLoaderInterface` implementation in `CountryType`, `LanguageType`, `LocaleType` and `CurrencyType`. Use the "choice_loader" option instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"choice_loader" should be enclosed by backticks too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecated the ChoiceLoaderInterface
implementation [...]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thank you.
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class CountryType extends AbstractType implements ChoiceLoaderInterface | ||
class CountryType extends AbstractType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not drop the implements
here. Technically, that's a BC break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted.
82381e4
to
e250dfa
Compare
Done. |
3f197b6
to
9592fa6
Compare
Thank you @yceruto. |
…hoice types (yceruto, fabpot) This PR was merged into the 4.1-dev branch. Discussion ---------- [Form] Add choice_translation_locale option for Intl choice types | Q | A | ------------- | --- | Branch? | master (4.2) | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #26737 | License | MIT | Doc PR | symfony/symfony-docs#... This PR adds possibility to show the list of elements for a custom locale different to the current one and proposes also deprecate the `ChoiceLoaderInterface` implementation from all of them, moving it to a separate class. See related issue #26737 for full description and use-case. After: ```php $formBuilder->add('country', CountryType::class, [ 'choice_translation_locale' => 'es', ]); ``` Alternative of #23629 TODO: - [x] Update `UPGRADE-*.md` and `src/**/CHANGELOG.md` files. - [x] Add some tests. Commits ------- 9592fa6 moved feature to 4.1 e250dfa Add choice_translation_locale option for Intl choice types
…nterface in intl forms (yceruto) This PR was merged into the 5.0-dev branch. Discussion ---------- [Form] Remove deprecated implementation of ChoiceLoaderInterface in intl forms | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - See previous PR symfony/symfony#26825 (4.1) Commits ------- b22cbf41c0 Remove deprecated implementation of ChoiceLoaderInterface in intl forms
…nterface in intl forms (yceruto) This PR was merged into the 5.0-dev branch. Discussion ---------- [Form] Remove deprecated implementation of ChoiceLoaderInterface in intl forms | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - See previous PR #26825 (4.1) Commits ------- b22cbf4 Remove deprecated implementation of ChoiceLoaderInterface in intl forms
This PR adds possibility to show the list of elements for a custom locale different to the current one and proposes also deprecate the
ChoiceLoaderInterface
implementation from all of them, moving it to a separate class.See related issue #26737 for full description and use-case.
After:
Alternative of #23629
TODO:
UPGRADE-*.md
andsrc/**/CHANGELOG.md
files.