@@ -694,8 +694,8 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
694
694
}
695
695
$ rootDir = $ container ->getParameter ('kernel.root_dir ' );
696
696
foreach ($ container ->getParameter ('kernel.bundles ' ) as $ bundle => $ class ) {
697
- $ reflection = new \ ReflectionClass ($ class );
698
- if (is_dir ($ dir = dirname ( $ reflection -> getFileName ()) .'/Resources/translations ' )) {
697
+ $ dirname = $ this -> getBundlePath ($ class );
698
+ if (is_dir ($ dir = $ dirname .'/Resources/translations ' )) {
699
8000
code>
699
$ dirs [] = $ dir ;
700
700
}
701
701
if (is_dir ($ dir = $ rootDir .sprintf ('/Resources/%s/translations ' , $ bundle ))) {
@@ -808,8 +808,7 @@ private function getValidatorMappingFiles(ContainerBuilder $container)
808
808
809
809
$ bundles = $ container ->getParameter ('kernel.bundles ' );
810
810
foreach ($ bundles as $ bundle ) {
811
- $ reflection = new \ReflectionClass ($ bundle );
812
- $ dirname = dirname ($ reflection ->getFileName ());
811
+ $ dirname = $ this ->getBundlePath ($ bundle );
813
812
814
813
if (is_file ($ file = $ dirname .'/Resources/config/validation.xml ' )) {
815
814
$ files [0 ][] = realpath ($ file );
@@ -923,8 +922,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
923
922
924
923
$ bundles = $ container ->getParameter ('kernel.bundles ' );
925
924
foreach ($ bundles as $ bundle ) {
926
- $ reflection = new \ReflectionClass ($ bundle );
927
- $ dirname = dirname ($ reflection ->getFileName ());
925
+ $ dirname = $ this ->getBundlePath ($ bundle );
928
926
929
927
if (is_file ($ file = $ dirname .'/Resources/config/serialization.xml ' )) {
930
928
$ definition = new Definition ('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader ' , array (realpath ($ file )));
@@ -990,6 +988,22 @@ private function getKernelRootHash(ContainerBuilder $container)
990
988
return $ this ->kernelRootHash ;
991
989
}
992
990
991
+ /**
992
+ * Gets the path of a given bundle using Bundle#getPath() when available.
993
+ *
994
+ * @param string $fqcn The bundle FQCN
995
+ *
996
+ * @return string
997
+ */
998
+ private function getBundlePath ($ fqcn )
999
+ {
1000
+ $ reflection = new \ReflectionClass ($ fqcn );
1001
+ $ getPathReflection = new \ReflectionMethod ($ fqcn , 'getPath ' );
1002
+ $ reflectionInstance = $ reflection ->newInstanceWithoutConstructor ();
1003
+
1004
+ return $ getPathReflection ->invoke ($ reflectionInstance ) ?: dirname ($ reflection ->getFilename ());
1005
+ }
1006
+
993
1007
/**
994
1008
* Returns the base path for the XSD files.
995
1009
*
0 commit comments