Skip to content

Commit

Permalink
Add missing resource tracking for validation mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
chalasr committed Mar 9, 2017
1 parent d236af6 commit 0a19cbe
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
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 0a19cbe

Please sign in to comment.