Update symfony validator

[MAILPOET-3241]
This commit is contained in:
Pavel Dohnal
2020-10-26 09:36:10 +01:00
committed by Veljko V
parent 1c993f5c46
commit 79d90514e2
4 changed files with 65 additions and 24 deletions

View File

@ -0,0 +1,14 @@
<?php
namespace MailPoet\Doctrine\Validator;
use MailPoetVendor\Symfony\Contracts\Translation\TranslatorTrait;
class Translator implements \MailPoetVendor\Symfony\Component\Translation\TranslatorInterface {
use TranslatorTrait;
public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null) {
return $this->trans($id, ['%count%' => $number] + $parameters, $domain, $locale);
}
}

View File

@ -19,6 +19,12 @@ class ValidatorFactory {
public function createValidator() { public function createValidator() {
$builder = Validation::createValidatorBuilder(); $builder = Validation::createValidatorBuilder();
// we need to use our own translator here.
// If we let the default translator to be used in the builder it uses an anonymous class and that is a problem
// All integration tests would fail with: [Exception] Serialization of 'class@anonymous' is not allowed
$translator = new Translator();
$translator->setLocale('en');
$builder->setTranslator($translator);
// annotation reader exists only in dev environment, on production cache is pre-generated // annotation reader exists only in dev environment, on production cache is pre-generated
$annotationReader = $this->annotationReaderProvider->getAnnotationReader(); $annotationReader = $this->annotationReaderProvider->getAnnotationReader();

View File

@ -17,7 +17,7 @@
"symfony/polyfill-mbstring": "1.18.1", "symfony/polyfill-mbstring": "1.18.1",
"symfony/polyfill-intl-normalizer": "1.18.1", "symfony/polyfill-intl-normalizer": "1.18.1",
"symfony/polyfill-php72": "1.18.1", "symfony/polyfill-php72": "1.18.1",
"symfony/validator": "3.4.43", "symfony/validator": "4.4.15",
"twig/twig": "2.13.1" "twig/twig": "2.13.1"
}, },
"scripts": { "scripts": {

67
prefixer/composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "59e4eb4f40871a749bfc3692dd5c01e6", "content-hash": "0e5e880782a299bfc64208dd53b7e3ae",
"packages": [ "packages": [
{ {
"name": "cerdic/css-tidy", "name": "cerdic/css-tidy",
@ -2579,62 +2579,69 @@
}, },
{ {
"name": "symfony/validator", "name": "symfony/validator",
"version": "v3.4.43", "version": "v4.4.15",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/validator.git", "url": "https://github.com/symfony/validator.git",
"reference": "008b41843e9e1a871ce13417c7e35ac1395e1bf2" "reference": "8da71f775b7e1ffeed784d27f526527bb8e9504b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/validator/zipball/008b41843e9e1a871ce13417c7e35ac1395e1bf2", "url": "https://api.github.com/repos/symfony/validator/zipball/8da71f775b7e1ffeed784d27f526527bb8e9504b",
"reference": "008b41843e9e1a871ce13417c7e35ac1395e1bf2", "reference": "8da71f775b7e1ffeed784d27f526527bb8e9504b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^5.5.9|>=7.0.8", "php": ">=7.1.3",
"symfony/polyfill-ctype": "~1.8", "symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-mbstring": "~1.0",
"symfony/translation": "~2.8|~3.0|~4.0" "symfony/translation-contracts": "^1.1|^2"
}, },
"conflict": { "conflict": {
"doctrine/lexer": "<1.0.2", "doctrine/lexer": "<1.0.2",
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",
"symfony/dependency-injection": "<3.3", "symfony/dependency-injection": "<3.4",
"symfony/http-kernel": "<3.3.5", "symfony/http-kernel": "<4.4",
"symfony/intl": "<4.3",
"symfony/translation": ">=5.0",
"symfony/yaml": "<3.4" "symfony/yaml": "<3.4"
}, },
"require-dev": { "require-dev": {
"doctrine/annotations": "~1.7", "doctrine/annotations": "~1.7",
"doctrine/cache": "~1.0", "doctrine/cache": "~1.0",
"egulias/email-validator": "^2.1.10", "egulias/email-validator": "^2.1.10",
"symfony/cache": "~3.1|~4.0", "symfony/cache": "^3.4|^4.0|^5.0",
"symfony/config": "~2.8|~3.0|~4.0", "symfony/config": "^3.4|^4.0|^5.0",
"symfony/dependency-injection": "~3.3|~4.0", "symfony/dependency-injection": "^3.4|^4.0|^5.0",
"symfony/expression-language": "~2.8|~3.0|~4.0", "symfony/expression-language": "^3.4|^4.0|^5.0",
"symfony/http-foundation": "~2.8|~3.0|~4.0", "symfony/http-client": "^4.3|^5.0",
"symfony/http-kernel": "^3.3.5|~4.0", "symfony/http-foundation": "^4.1|^5.0",
"symfony/intl": "^2.8.18|^3.2.5|~4.0", "symfony/http-kernel": "^4.4",
"symfony/property-access": "~2.8|~3.0|~4.0", "symfony/intl": "^4.3|^5.0",
"symfony/var-dumper": "~3.3|~4.0", "symfony/mime": "^4.4|^5.0",
"symfony/yaml": "~3.4|~4.0" "symfony/property-access": "^3.4|^4.0|^5.0",
"symfony/property-info": "^3.4|^4.0|^5.0",
"symfony/translation": "^4.2",
"symfony/yaml": "^3.4|^4.0|^5.0"
}, },
"suggest": { "suggest": {
"doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.",
"doctrine/cache": "For using the default cached annotation reader and metadata cache.", "doctrine/cache": "For using the default cached annotation reader.",
"egulias/email-validator": "Strict (RFC compliant) email validation", "egulias/email-validator": "Strict (RFC compliant) email validation",
"psr/cache-implementation": "For using the metadata cache.", "psr/cache-implementation": "For using the mapping cache.",
"symfony/config": "", "symfony/config": "",
"symfony/expression-language": "For using the Expression validator", "symfony/expression-language": "For using the Expression validator",
"symfony/http-foundation": "", "symfony/http-foundation": "",
"symfony/intl": "", "symfony/intl": "",
"symfony/property-access": "For accessing properties within comparison constraints", "symfony/property-access": "For accessing properties within comparison constraints",
"symfony/property-info": "To automatically add NotNull and Type constraints",
"symfony/translation": "For translating validation errors.",
"symfony/yaml": "" "symfony/yaml": ""
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.4-dev" "dev-master": "4.4-dev"
} }
}, },
"autoload": { "autoload": {
@ -2661,7 +2668,21 @@
], ],
"description": "Symfony Validator Component", "description": "Symfony Validator Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2020-06-29T10:55:42+00:00" "funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-09-27T03:36:23+00:00"
}, },
{ {
"name": "twig/twig", "name": "twig/twig",