2424use Symfony \Component \DependencyInjection \Reference ;
2525use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
2626use Symfony \Component \Config \Resource \FileResource ;
27- use Symfony \Component \Config \Resource \DirectoryResource ;
2827use Symfony \Component \Finder \Finder ;
2928use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
3029use Symfony \Component \Config \FileLocator ;
@@ -875,32 +874,28 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
875874 }
876875 $ rootDir = $ container ->getParameter ('kernel.root_dir ' );
877876 foreach ($ container ->getParameter ('kernel.bundles_metadata ' ) as $ name => $ bundle ) {
878- if (is_dir ($ dir = $ bundle ['path ' ].'/Resources/translations ' )) {
877+ if ($ container -> fileExists ($ dir = $ bundle ['path ' ].'/Resources/translations ' )) {
879878 $ dirs [] = $ dir ;
880879 }
881- if (is_dir ($ dir = $ rootDir .sprintf ('/Resources/%s/translations ' , $ name ))) {
880+ if ($ container -> fileExists ($ dir = $ rootDir .sprintf ('/Resources/%s/translations ' , $ name ))) {
882881 $ dirs [] = $ dir ;
883882 }
884883 }
885884
886885 foreach ($ config ['paths ' ] as $ dir ) {
887- if (is_dir ($ dir )) {
886+ if ($ container -> fileExists ($ dir )) {
888887 $ dirs [] = $ dir ;
889888 } else {
890889 throw new \UnexpectedValueException (sprintf ('%s defined in translator.paths does not exist or is not a directory ' , $ dir ));
891890 }
892891 }
893892
894- if (is_dir ($ dir = $ rootDir .'/Resources/translations ' )) {
893+ if ($ container -> fileExists ($ dir = $ rootDir .'/Resources/translations ' )) {
895894 $ dirs [] = $ dir ;
896895 }
897896
898897 // Register translation resources
899898 if ($ dirs ) {
900- foreach ($ dirs as $ dir ) {
901- $ container ->addResource (new DirectoryResource ($ dir ));
902- }
903-
904899 $ files = array ();
905900 $ finder = Finder::create ()
906901 ->followLinks ()
@@ -1006,19 +1001,16 @@ private function getValidatorMappingFiles(ContainerBuilder $container, array &$f
10061001 foreach ($ container ->getParameter ('kernel.bundles_metadata ' ) as $ bundle ) {
10071002 $ dirname = $ bundle ['path ' ];
10081003
1009- if (is_file ($ file = $ dirname .'/Resources/config/validation.yml ' )) {
1004+ if ($ container -> fileExists ($ file = $ dirname .'/Resources/config/validation.yml ' , false )) {
10101005 $ files ['yml ' ][] = $ file ;
1011- $ container ->addResource (new FileResource ($ file ));
10121006 }
10131007
1014- if (is_file ($ file = $ dirname .'/Resources/config/validation.xml ' )) {
1008+ if ($ container -> fileExists ($ file = $ dirname .'/Resources/config/validation.xml ' , false )) {
10151009 $ files ['xml ' ][] = $ file ;
1016- $ container ->addResource (new FileResource ($ file ));
10171010 }
10181011
1019- if (is_dir ($ dir = $ dirname .'/Resources/config/validation ' )) {
1012+ if ($ container -> fileExists ($ dir = $ dirname .'/Resources/config/validation ' )) {
10201013 $ this ->getValidatorMappingFilesFromDir ($ dir , $ files );
1021- $ container ->addResource (new DirectoryResource ($ dir ));
10221014 }
10231015 }
10241016 }
@@ -1202,23 +1194,21 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
12021194 foreach ($ container ->getParameter ('kernel.bundles_metadata ' ) as $ bundle ) {
12031195 $ dirname = $ bundle ['path ' ];
12041196
1205- if (is_file ($ file = $ dirname .'/Resources/config/serialization.xml ' )) {
1197+ if ($ container -> fileExists ($ file = $ dirname .'/Resources/config/serialization.xml ' , false )) {
12061198 $ definition = new Definition ('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader ' , array ($ file ));
12071199 $ definition ->setPublic (false );
12081200
12091201 $ serializerLoaders [] = $ definition ;
1210- $ container ->addResource (new FileResource ($ file ));
12111202 }
12121203
1213- if (is_file ($ file = $ dirname .'/Resources/config/serialization.yml ' )) {
1204+ if ($ container -> fileExists ($ file = $ dirname .'/Resources/config/serialization.yml ' , false )) {
12141205 $ definition = new Definition ('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader ' , array ($ file ));
12151206 $ definition ->setPublic (false );
12161207
12171208 $ serializerLoaders [] = $ definition ;
1218- $ container ->addResource (new FileResource ($ file ));
12191209 }
12201210
1221- if (is_dir ($ dir = $ dirname .'/Resources/config/serialization ' )) {
1211+ if ($ container -> fileExists ($ dir = $ dirname .'/Resources/config/serialization ' )) {
12221212 foreach (Finder::create ()->followLinks ()->files ()->in ($ dir )->name ('*.xml ' ) as $ file ) {
12231213 $ definition = new Definition ('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader ' , array ($ file ->getPathname ()));
12241214 $ definition ->setPublic (false );
@@ -1231,8 +1221,6 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
12311221
12321222 $ serializerLoaders [] = $ definition ;
12331223 }
1234-
1235- $ container ->addResource (new DirectoryResource ($ dir ));
12361224 }
12371225 }
12381226
0 commit comments