Skip to content

Commit

Permalink
bug #21927 [FrameworkBundle] Add missing resource tracking for valida…
Browse files Browse the repository at this point in the history
…tion mapping (chalasr)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[FrameworkBundle] Add missing resource tracking for validation mapping

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #19086 (comment)
| License       | MIT
| Doc PR        | n/a

https://github.com/symfony/symfony/pull/21927/files?w=1

Commits
-------

0a19cbe Add missing resource tracking for validation mapping
  • Loading branch information
nicolas-grekas committed Mar 9, 2017
2 parents 5b1a96a + 0a19cbe commit 64f9f7b
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -15,6 +15,7 @@
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\DirectoryResource;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -938,7 +939,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder

$files = array('xml' => array(), 'yml' => array());
$this->getValidatorMappingFiles($container, $files);
$this->getValidatorMappingFilesFromConfig($config, $files);
$this->getValidatorMappingFilesFromConfig($container, $config, $files);

if (!empty($files['xml'])) {
$validatorBuilder->addMethodCall('addXmlMappings', array($files['xml']));
Expand Down Expand Up @@ -997,7 +998,7 @@ private function getValidatorMappingFiles(ContainerBuilder $container, array &$f
$files['xml'][] = $file;
}

if ($container->fileExists($dir = $dirname.'/Resources/config/validation')) {
if ($container->fileExists($dir = $dirname.'/Resources/config/validation', '/^$/')) {
$this->getValidatorMappingFilesFromDir($dir, $files);
}
}
Expand All @@ -1011,12 +1012,13 @@ private function getValidatorMappingFilesFromDir($dir, array &$files)
}
}

private function getValidatorMappingFilesFromConfig(array $config, array &$files)
private function getValidatorMappingFilesFromConfig(ContainerBuilder $container, array $config, array &$files)
{
foreach ($config['mapping']['paths'] as $path) {
if (is_dir($path)) {
$this->getValidatorMappingFilesFromDir($path, $files);
} elseif (is_file($path)) {
$container->addResource(new DirectoryResource($path, '/^$/'));
} elseif ($container->fileExists($path, false)) {
if (preg_match('/\.(xml|ya?ml)$/', $path, $matches)) {
$extension = $matches[1];
$files['yaml' === $extension ? 'yml' : $extension][] = $path;
Expand Down

0 comments on commit 64f9f7b

Please sign in to comment.