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

Commitd25a0c8

Browse files
committed
[form] lazy transpost_max_size_message.
1 parentf876473 commitd25a0c8

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

‎src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class UploadValidatorExtension extends AbstractTypeExtension
2424
{
2525
private$translator;
2626
private$translationDomain;
27+
private$errorMessage ='post_max_size_message';
2728

2829
/**
2930
* @param TranslatorInterface $translator The translator for translating error messages
@@ -40,11 +41,11 @@ public function __construct(TranslatorInterface $translator, $translationDomain
4041
*/
4142
publicfunctionconfigureOptions(OptionsResolver$resolver)
4243
{
43-
$translator =$this->translator;
44-
$translationDomain =$this->translationDomain;
44+
$self =$this;
45+
$resolver->setNormalizer('post_max_size_message',function (Options$options,$errorMessage)use ($self) {
46+
$self->setErrorMessage($errorMessage);
4547

46-
$resolver->setNormalizer('post_max_size_message',function (Options$options,$errorMessage)use ($translator,$translationDomain) {
47-
return$translator->trans($errorMessage,array(),$translationDomain);
48+
return$self;
4849
});
4950
}
5051

@@ -55,4 +56,19 @@ public function getExtendedType()
5556
{
5657
return'form';
5758
}
59+
60+
publicfunction__toString()
61+
{
62+
return$this->translator->trans($this->errorMessage,array(),$this->translationDomain);
63+
}
64+
65+
/**
66+
* This method is public because it needs to be callable from a closure in PHP 5.3.
67+
*
68+
* @internal
69+
*/
70+
publicfunctionsetErrorMessage($errorMessage)
71+
{
72+
$this->errorMessage =$errorMessage;
73+
}
5874
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp