8000 bug #24856 [FrameworkBundle] Add default mapping path for validator c… · symfony/symfony@c549e3c · GitHub
[go: up one dir, main page]

Skip to content

Commit c549e3c

Browse files
committed
bug #24856 [FrameworkBundle] Add default mapping path for validator component in bundle-less app (yceruto)
This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle] Add default mapping path for validator component in bundle-less app | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | ToDo Same approach of #24833 Commits ------- 4e0daec Add default mapping path for validator component
2 parents 93f206e + 4e0daec commit c549e3c

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,11 @@ private function registerValidatorMapping(ContainerBuilder $container, array $co
12911291
}
12921292
}
12931293

1294+
$projectDir = $container->getParameter('kernel.project_dir');
1295+
if ($container->fileExists($dir = $projectDir.'/config/validator', '/^$/')) {
1296+
$this->registerMappingFilesFromDir($dir, $fileRecorder);
1297+
}
1298+
12941299
$this->registerMappingFilesFromConfig($container, $config, $fileRecorder);
12951300
}
12961301

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,13 @@ public function testTemplatingRequiresAtLeastOneEngine()
543543
public function testValidation()
544544
{
545545
$container = $this->createContainerFromFile('full');
546+
$projectDir = $container->getParameter('kernel.project_dir');
546547

547548
$ref = new \ReflectionClass('Symfony\Component\Form\Form');
548-
$xmlMappings = array(dirname($ref->getFileName()).'/Resources/config/validation.xml');
549+
$xmlMappings = array(
550+
dirname($ref->getFileName()).'/Resources/config/validation.xml',
551+
strtr($projectDir.'/config/validator/foo.xml', '/', DIRECTORY_SEPARATOR),
552+
);
549553

550554
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
551555

@@ -633,7 +637,7 @@ public function testValidationPaths()
633637
$this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[7][1]);
634638

635639
$xmlMappings = $calls[3][1][0];
636-
$this->assertCount(2, $xmlMappings);
640+
$this->assertCount(3, $xmlMappings);
637641
try {
638642
// Testing symfony/symfony
639643
$this->assertStringEndsWith('Component'.DIRECTORY_SEPARATOR.'Form/Resources/config/validation.xml', $xmlMappings[0]);
@@ -659,7 +663,7 @@ public function testValidationPathsUsingCustomBundlePath()
659663

660664
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
661665
$xmlMappings = $calls[3][1][0];
662-
$this->assertCount(2, $xmlMappings);
666+
$this->assertCount(3, $xmlMappings);
663667

664668
try {
665669
// Testing symfony/symfony
@@ -701,7 +705,7 @@ public function testValidationMapping()
701705
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
702706

703707
$this->assertSame('addXmlMappings', $calls[3][0]);
704-
$this->assertCount(2, $calls[3][1][0]);
708+
$this->assertCount(3, $calls[3][1][0]);
705709

706710
$this->assertSame('addYamlMappings', $calls[4][0]);
707711
$this->assertCount(3, $calls[4][1][0]);

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/config/validator/foo.xml

Whitespace-only changes.

0 commit comments

Comments
 (0)
0