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

Appearance settings

[FrameworkBundle] [Validator] Legacy Translator Checking #31154

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

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
FWB - Legacy translator check
  • Loading branch information
snebes committed Apr 18, 2019
commit 331a885d32b2b2233fe38ebff75f3f150867e449
Original file line number Diff line number Diff line change
Expand Up @@ -1108,12 +1108,6 @@ private function registerValidationConfiguration(array $config, ContainerBuilder

$validatorBuilder = $container->getDefinition('validator.builder');

if (class_exists(LegacyTranslatorProxy::class)) {
$calls = $validatorBuilder->getMethodCalls();
$calls[1] = ['setTranslator', [new Definition(LegacyTranslatorProxy::class, [new Reference('translator')])]];
$validatorBuilder->setMethodCalls($calls);
}

$container->setParameter('validator.translation_domain', $config['translation_domain']);

$files = ['xml' => [], 'yml' => []];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,11 +819,7 @@ public function testValidation()
$this->assertSame('setConstraintValidatorFactory', $calls[0][0]);
$this->assertEquals([new Reference('validator.validator_factory')], $calls[0][1]);
$this->assertSame('setTranslator', $calls[1][0]);
if (class_exists(LegacyTranslatorProxy::class)) {
$this->assertEquals([new Definition(LegacyTranslatorProxy::class, [new Reference('translator')])], $calls[1][1]);
} else {
$this->assertEquals([new Reference('translator')], $calls[1][1]);
}
$this->assertEquals([new Reference('translator')], $calls[1][1]);
$this->assertSame('setTranslationDomain', $calls[2][0]);
$this->assertSame(['%validator.translation_domain%'], $calls[2][1]);
$this->assertSame('addXmlMappings', $calls[3][0]);
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"symfony/polyfill-mbstring": "~1.0",
"symfony/filesystem": "~3.4|~4.0",
"symfony/finder": "~3.4|~4.0",
"symfony/routing": "^4.1",
"symfony/translation": "^4.2"
"symfony/routing": "^4.1"
},
"require-dev": {
"doctrine/cache": "~1.0",
Expand All @@ -49,6 +48,7 @@
"symfony/security-csrf": "~3.4|~4.0",
"symfony/serializer": "^4.2",
"symfony/stopwatch": "~3.4|~4.0",
"symfony/translation": "~4.2",
"symfony/templating": "~3.4|~4.0",
"symfony/validator": "^4.1",
"symfony/var-dumper": "~3.4|~4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function process(ContainerBuilder $container)
$translator = $translator->getParent();
}

if (!is_subclass_of($class, LegacyTranslatorInterface::class)) {
if (class_exists(LegacyTranslatorProxy::class)) {
$arguments[0] = (new Definition(LegacyTranslatorProxy::class))->addArgument($arguments[0]);
}
}
Expand Down
6 changes: 1 addition & 5 deletions 6 src/Symfony/Component/Validator/ValidatorBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,7 @@ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterfac
*/
public function setTranslator(LegacyTranslatorInterface $translator)
{
$this->translator = $translator;

while ($this->translator instanceof LegacyTranslatorProxy) {
$this->translator = $this->translator->getTranslator();
}
$this->translator = $translator instanceof LegacyTranslatorProxy ? $translator->getTranslator() : $translator;

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Validator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"php": "^7.1.3",
"symfony/contracts": "^1.0.2",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0"
"symfony/polyfill-mbstring": "~1.0",
"symfony/translation": "~4.2"
Copy link
Author

@snebes snebes Apr 18, 2019

Choose a reason for hiding this comment

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

I moved this into the require section since LegacyTranslatorProxy includes a reference still to the old interface.

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Util/LegacyTranslatorProxy.php#L14

},
"require-dev": {
"symfony/http-foundation": "~4.1",
Expand All @@ -32,7 +33,6 @@
"symfony/expression-language": "~3.4|~4.0",
"symfony/cache": "~3.4|~4.0",
"symfony/property-access": "~3.4|~4.0",
"symfony/translation": "~4.2",
"doctrine/annotations": "~1.0",
"doctrine/cache": "~1.0",
"egulias/email-validator": "^1.2.8|~2.0"
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.