24
24
use Symfony \Component \DependencyInjection \Reference ;
25
25
use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
26
26
use Symfony \Component \Config \Resource \FileResource ;
27
- use Symfony \Component \Config \Resource \DirectoryResource ;
28
27
use Symfony \Component \Finder \Finder ;
29
28
use Symfony \Component \HttpKernel \DependencyInjection \Extension ;
30
29
use Symfony \Component \Config \FileLocator ;
@@ -877,32 +876,28 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
877
876
}
878
877
$ rootDir = $ container ->getParameter ('kernel.root_dir ' );
879
878
foreach ($ container ->getParameter ('kernel.bundles_metadata ' ) as $ name => $ bundle ) {
880
- if (is_dir ($ dir = $ bundle ['path ' ].'/Resources/translations ' )) {
879
+ if ($ container -> fileExists ($ dir = $ bundle ['path ' ].'/Resources/translations ' )) {
881
880
$ dirs [] = $ dir ;
882
881
}
883
- if (is_dir ($ dir = $ rootDir .sprintf ('/Resources/%s/translations ' , $ name ))) {
882
+ if ($ container -> fileExists ($ dir = $ rootDir .sprintf ('/Resources/%s/translations ' , $ name ))) {
884
883
$ dirs [] = $ dir ;
885
884
}
886
885
}
887
886
888
887
foreach ($ config ['paths ' ] as $ dir ) {
889
- if (is_dir ($ dir )) {
888
+ if ($ container -> fileExists ($ dir )) {
890
889
$ dirs [] = $ dir ;
891
890
} else {
892
891
throw new \UnexpectedValueException (sprintf ('%s defined in translator.paths does not exist or is not a directory ' , $ dir ));
893
892
}
894
893
}
895
894
896
- if (is_dir ($ dir = $ rootDir .'/Resources/translations ' )) {
895
+ if ($ container -> fileExists ($ dir = $ rootDir .'/Resources/translations ' )) {
897
896
$ dirs [] = $ dir ;
898
897
}
899
898
900
899
// Register translation resources
901
900
if ($ dirs ) {
902
- foreach ($ dirs as $ dir ) {
903
- $ container ->addResource (new DirectoryResource ($ dir ));
904
- }
905
-
906
901
$ files = array ();
907
902
$ finder = Finder::create ()
908
903
->followLinks ()
@@ -1008,19 +1003,16 @@ private function getValidatorMappingFiles(ContainerBuilder $container, array &$f
1008
1003
foreach ($ container ->getParameter ('kernel.bundles_metadata ' ) as $ bundle ) {
1009
1004
$ dirname = $ bundle ['path ' ];
1010
1005
1011
- if (is_file ($ file = $ dirname .'/Resources/config/validation.yml ' )) {
1006
+ if ($ container -> fileExists ($ file = $ dirname .'/Resources/config/validation.yml ' , false )) {
1012
1007
$ files ['yml ' ][] = $ file ;
1013
- $ container ->addResource (new FileResource ($ file ));
1014
1008
}
1015
1009
1016
- if (is_file ($ file = $ dirname .'/Resources/config/validation.xml ' )) {
1010
+ if ($ container -> fileExists ($ file = $ dirname .'/Resources/config/validation.xml ' , false )) {
1017
1011
$ files ['xml ' ][] = $ file ;
1018
- $ container ->addResource (new FileResource ($ file ));
1019
1012
}
1020
1013
1021
- if (is_dir ($ dir = $ dirname .'/Resources/config/validation ' )) {
1014
+ if ($ container -> fileExists ($ dir = $ dirname .'/Resources/config/validation ' )) {
1022
1015
$ this ->getValidatorMappingFilesFromDir ($ dir , $ files );
1023
- $ container ->addResource (new DirectoryResource ($ dir ));
1024
1016
}
1025
1017
}
1026
1018
}
@@ -1204,23 +1196,21 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
1204
1196
foreach ($ container ->getParameter ('kernel.bundles_metadata ' ) as $ bundle ) {
1205
1197
$ dirname = $ bundle ['path ' ];
1206
1198
1207
- if (is_file ($ file = $ dirname .'/Resources/config/serialization.xml ' )) {
1199
+ if ($ container -> fileExists ($ file = $ dirname .'/Resources/config/serialization.xml ' )) {
1208
1200
$ definition = new Definition ('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader ' , array ($ file ));
1209
1201
$ definition ->setPublic (false );
1210
1202
1211
1203
$ serializerLoaders [] = $ definition ;
1212
- $ container ->addResource (new FileResource ($ file ));
1213
1204
}
1214
1205
1215
- if (is_file ($ file = $ dirname .'/Resources/config/serialization.yml ' )) {
1206
+ if ($ container -> fileExists ($ file = $ dirname .'/Resources/config/serialization.yml ' , false )) {
1216
1207
$ definition = new Definition ('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader ' , array ($ file ));
1217
1208
$ definition ->setPublic (false );
1218
1209
1219
1210
$ serializerLoaders [] = $ definition ;
1220
- $ container ->addResource (new FileResource ($ file ));
1221
1211
}
1222
1212
1223
- if (is_dir ($ dir = $ dirname .'/Resources/config/serialization ' )) {
1213
+ if ($ container -> fileExists ($ dir = $ dirname .'/Resources/config/serialization ' )) {
1224
1214
foreach (Finder::create ()->followLinks ()->files ()->in ($ dir )->name ('*.xml ' ) as $ file ) {
1225
1215
$ definition = new Definition ('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader ' , array ($ file ->getPathname ()));
1226
1216
$ definition ->setPublic (false );
@@ -1233,8 +1223,6 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
1233
1223
1234
1224
$ serializerLoaders [] = $ definition ;
1235
1225
}
1236
-
1237
- $ container ->addResource (new DirectoryResource ($ dir ));
1238
1226
}
1239
1227
}
1240
1228
0 commit comments