8000 Add default mapping path for validator component · symfony/symfony@4e0daec · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e0daec

Browse files
committed
Add default mapping path for validator component
1 parent b2edd51 commit 4e0daec

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
@@ -1290,6 +1290,11 @@ private function registerValidatorMapping(ContainerBuilder $container, array $co
12901290
}
12911291
}
12921292

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

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
6396 D0E7 43
$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