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