15
15
use Symfony \Bridge \Monolog \Processor \DebugProcessor ;
16
16
use Symfony \Component \Cache \Adapter \AdapterInterface ;
17
17
use Symfony \Component \Config \Loader \LoaderInterface ;
18
+ use Symfony \Component \Config \Resource \DirectoryResource ;
18
19
use Symfony \Component \DependencyInjection \Alias ;
19
20
use Symfony \Component \DependencyInjection \ChildDefinition ;
20
21
use Symfony \Component \DependencyInjection \ContainerBuilder ;
@@ -938,7 +939,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
938
939
939
940
$ files = array ('xml ' => array (), 'yml ' => array ());
940
941
$ this ->getValidatorMappingFiles ($ container , $ files );
941
- $ this ->getValidatorMappingFilesFromConfig ($ config , $ files );
942
+ $ this ->getValidatorMappingFilesFromConfig ($ container , $ config , $ files );
942
943
943
944
if (!empty ($ files ['xml ' ])) {
944
945
$ validatorBuilder ->addMethodCall ('addXmlMappings ' , array ($ files ['xml ' ]));
@@ -997,7 +998,7 @@ private function getValidatorMappingFiles(ContainerBuilder $container, array &$f
997
998
$ files ['xml ' ][] = $ file ;
998
999
}
999
1000
1000
- if ($ container ->fileExists ($ dir = $ dirname .'/Resources/config/validation ' )) {
1001
+ if ($ container ->fileExists ($ dir = $ dirname .'/Resources/config/validation ' , ' /^$/ ' )) {
1001
1002
$ this ->getValidatorMappingFilesFromDir ($ dir , $ files );
1002
1003
}
1003
1004
}
@@ -1011,12 +1012,13 @@ private function getValidatorMappingFilesFromDir($dir, array &$files)
1011
1012
}
1012
1013
}
1013
1014
1014
- private function getValidatorMappingFilesFromConfig (array $ config , array &$ files )
1015
+ private function getValidatorMappingFilesFromConfig (ContainerBuilder $ container , array $ config , array &$ files )
1015
1016
{
1016
1017
foreach ($ config ['mapping ' ]['paths ' ] as $ path ) {
1017
1018
if (is_dir ($ path )) {
1018
1019
$ this ->getValidatorMappingFilesFromDir ($ path , $ files );
1019
- } elseif (is_file ($ path )) {
1020
+ $ container ->addResource (new DirectoryResource ($ path , '/^$/ ' ));
1021
+ } elseif ($ container ->fileExists ($ path , false )) {
1020
1022
if (preg_match ('/\.(xml|ya?ml)$/ ' , $ path , $ matches )) {
1021
1023
$ extension = $ matches [1 ];
1022
1024
$ files ['yaml ' === $ extension ? 'yml ' : $ extension ][] = $ path ;
0 commit comments