Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
c81bf25 tob26715fCompareb26715f to1480bbdCompare| // 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 eachChoiceLoaderInterface 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 theChoiceLoaderInterface's methods without modifying them? We indeed target to remove theChoiceLoaderInterface 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 inhttps://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 overridingloadChoiceList() 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, likereturn 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!
ogizanagi left a comment
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 :)
| { | ||
| /** | ||
| *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 theChoiceLoaderInterface's methods without modifying them? We indeed target to remove theChoiceLoaderInterface from all of these types, right?
b4c0658 to59d4d00Compareyceruto commentedApr 8, 2018
@ogizanagi thank you for this review. Status: Waiting consensus on depreciation path :) |
yceruto commentedApr 8, 2018
Status: Needs Review |
bbc7834 toa69b31fComparea69b31f toa4797acCompareyceruto commentedApr 18, 2018
Just squashing commits, ready on my side. |
fabpot left a comment
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
| */ | ||
| publicfunctionloadChoiceList($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 theChoiceLoaderInterface 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.
| useSymfony\Component\OptionsResolver\OptionsResolver; | ||
| class CountryTypeextends AbstractTypeimplements ChoiceLoaderInterface | ||
| class CountryTypeextends 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 theimplements 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 toe250dfaCompareyceruto commentedApr 20, 2018
Done. |
3f197b6 to9592fa6Comparefabpot commentedApr 22, 2018
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#23629TODO:- [x] Update `UPGRADE-*.md` and `src/**/CHANGELOG.md` files.- [x] Add some tests.Commits-------9592fa6 moved feature to 4.1e250dfa 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 PRsymfony/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
Uh oh!
There was an error while loading.Please reload this page.
This PR adds possibility to show the list of elements for a custom locale different to the current one and proposes also deprecate the
ChoiceLoaderInterfaceimplementation 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-*.mdandsrc/**/CHANGELOG.mdfiles.