-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FORM] fix post_max_size_message translation (alt. 2) #19061
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
DavidBadura
commented
Jun 15, 2016
Q | A |
---|---|
Branch? | 2.7 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #15479, #18543 |
License | MIT |
Doc PR | - |
*/ | ||
public function getExtendedType() | ||
{ | ||
return FormType::class; |
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.
Should be 'form'
as it targets 2.7 and to be changed in 2.8.
comments addressed |
$translator = $this->translator; | ||
|
||
$resolver->setNormalizer('post_max_size_message', function (Options $options, $errorMessage) use ($translator) { | ||
return $translator->trans($errorMessage, array(), $this->translationDomain); |
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.
Why not just use $this->translator
directly as done with $this->translationDomain
?
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.
Symfony 2.7 need to be compatible with php5.3 so we can't use $this
in closures, the $this->translationDomain
needs to be replaced.
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.
oh, that's wrong. $this in anonymous function you can use starting 5.4.
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
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.
👍
It seems weird to create an extension for this, but I think I like this implementation more than the one in #18543, just because it is less intrusive as a bug fix for 2.7. 👍 |
@@ -189,5 +189,10 @@ | |||
<service id="form.type_extension.submit.validator" class="Symfony\Component\Form\Extension\Validator\Type\SubmitTypeValidatorExtension"> | |||
<tag name="form.type_extension" alias="submit" /> | |||
</service> | |||
<service id="form.type_extension.upload.validator" class="Symfony\Component\Form\Extension\Validator\Type\UploadValidatorExtension"> | |||
<tag name="form.type_extension" alias="form" /> |
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.
If I'm not wrong alias
is not used anymore
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.
Sorry I forgot this target 2.7 :)
👍 |
Thank you @DavidBadura. |
…id Badura) This PR was merged into the 2.7 branch. Discussion ---------- [FORM] fix post_max_size_message translation (alt. 2) | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15479, #18543 | License | MIT | Doc PR | - Commits ------- 9d8a5e5 fix post_max_size_message translation
… 2.8 (Tobion) This PR was merged into the 2.8 branch. Discussion ---------- [Form] fix post max size translation type extension for >= 2.8 | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? |no | Tests pass? | yes | Fixed tickets | #19210, #19061 | License | MIT | Doc PR | Commits ------- a27ec00 [Form] fix post max size translation type extension for >= 2.8