Skip to content

[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

Merged
merged 1 commit into from
Jun 22, 2016
Merged

[FORM] fix post_max_size_message translation (alt. 2) #19061

merged 1 commit into from
Jun 22, 2016

Conversation

DavidBadura
Copy link
Contributor

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 -

@DavidBadura DavidBadura changed the title [FORM] fix post_max_size_message translation [FORM] fix post_max_size_message translation (alt. 2) Jun 15, 2016
*/
public function getExtendedType()
{
return FormType::class;
Copy link
Contributor

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.

@DavidBadura
Copy link
Contributor Author

comments addressed

$translator = $this->translator;

$resolver->setNormalizer('post_max_size_message', function (Options $options, $errorMessage) use ($translator) {
return $translator->trans($errorMessage, array(), $this->translationDomain);
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@fabpot
Copy link
Member

fabpot commented Jun 22, 2016

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.

👍
ping @symfony/deciders

@@ -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" />
Copy link
Contributor

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

Copy link
Contributor

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 :)

@HeahDude
Copy link
Contributor

👍

@fabpot
Copy link
Member

fabpot commented Jun 22, 2016

Thank you @DavidBadura.

@fabpot fabpot merged commit 9d8a5e5 into symfony:2.7 Jun 22, 2016
fabpot added a commit that referenced this pull request Jun 22, 2016
…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
@DavidBadura DavidBadura deleted the fix-form-upload-translation2 branch June 22, 2016 14:11
fabpot added a commit that referenced this pull request Jun 29, 2016
… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants