@@ -73,9 +73,11 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
73
73
74
74
if ($ mappingConfig ['is_bundle ' ]) {
75
75
$ bundle = null ;
76
+ $ bundleMetadata = null ;
76
77
foreach ($ container ->getParameter ('kernel.bundles ' ) as $ name => $ class ) {
77
78
if ($ mappingName === $ name ) {
78
79
$ bundle = new \ReflectionClass ($ class );
80
+ $ bundleMetadata = $ container ->getParameter ('kernel.bundles_metadata ' )[$ name ];
79
81
80
82
break ;
81
83
}
@@ -85,7 +87,7 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
85
87
throw new \InvalidArgumentException (sprintf ('Bundle "%s" does not exist or it is not enabled. ' , $ mappingName ));
86
88
}
87
89
88
- $ mappingConfig = $ this ->getMappingDriverBundleConfigDefaults ($ mappingConfig , $ bundle , $ container );
90
+ $ mappingConfig = $ this ->getMappingDriverBundleConfigDefaults ($ mappingConfig , $ bundle , $ container, $ bundleMetadata [ ' path ' ] );
89
91
if (!$ mappingConfig ) {
90
92
continue ;
91
93
}
@@ -133,11 +135,20 @@ protected function setMappingDriverConfig(array $mappingConfig, string $mappingN
133
135
*
134
136
* Returns false when autodetection failed, an array of the completed information otherwise.
135
137
*
138
+ * @param string|null $bundleDir The bundle directory path
139
+ *
136
140
* @return array|false
137
141
*/
138
- protected function getMappingDriverBundleConfigDefaults (array $ bundleConfig , \ReflectionClass $ bundle , ContainerBuilder $ container )
142
+ protected function getMappingDriverBundleConfigDefaults (array $ bundleConfig , \ReflectionClass $ bundle , ContainerBuilder $ container/*, string $bundleDir = null*/ )
139
143
{
140
- $ bundleDir = \dirname ($ bundle ->getFileName ());
144
+ if (\func_num_args () < 4 && __CLASS__ !== static ::class && __CLASS__ !== (new \ReflectionMethod ($ this , __FUNCTION__ ))->getDeclaringClass ()->getName () && !$ this instanceof \PHPUnit \Framework \MockObject \MockObject && !$ this instanceof \Prophecy \Prophecy \ProphecySubjectInterface && !$ this instanceof \Mockery \MockInterface) {
145
+ trigger_deprecation ('symfony/doctrine-bridge ' , '5.4 ' , 'The "%s()" method will have a new "string $bundleDir = null" argument in version 6.0, not defining it is deprecated. ' , __METHOD__ );
146
+ $ bundleDir = null ;
147
+ } else {
148
+ $ bundleDir = func_get_arg (3 );
149
+ }
150
+
151
+ $ bundleDir ?? $ bundleDir = \dirname ($ bundle ->getFileName ());
141
152
142
153
if (!$ bundleConfig ['type ' ]) {
143
154
$ bundleConfig ['type ' ] = $ this ->detectMetadataDriver ($ bundleDir , $ container );
@@ -152,7 +163,7 @@ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \Re
152
163
if (\in_array ($ bundleConfig ['type ' ], ['annotation ' , 'staticphp ' , 'attribute ' ])) {
153
164
$ bundleConfig ['dir ' ] = $ bundleDir .'/ ' .$ this ->getMappingObjectDefaultName ();
154
165
} else {
155
- $ bundleConfig ['dir ' ] = $ bundleDir .'/ ' .$ this ->getMappingResourceConfigDirectory ();
166
+ $ bundleConfig ['dir ' ] = $ bundleDir .'/ ' .$ this ->getMappingResourceConfigDirectory ($ bundleDir );
156
167
}
157
168
} else {
158
169
$ bundleConfig ['dir ' ] = $ bundleDir .'/ ' .$ bundleConfig ['dir ' ];
@@ -246,7 +257,7 @@ protected function assertValidMappingConfiguration(array $mappingConfig, string
246
257
*/
247
258
protected function detectMetadataDriver (string $ dir , ContainerBuilder $ container )
248
259
{
249
- $ configPath = $ this ->getMappingResourceConfigDirectory ();
260
+ $ configPath = $ this ->getMappingResourceConfigDirectory ($ dir );
250
261
$ extension = $ this ->getMappingResourceExtension ();
251
262
252
263
if (glob ($ dir .'/ ' .$ configPath .'/*. ' .$ extension .'.xml ' , \GLOB_NOSORT )) {
@@ -440,9 +451,11 @@ abstract protected function getMappingObjectDefaultName();
440
451
/**
441
452
* Relative path from the bundle root to the directory where mapping files reside.
442
453
*
454
+ * @param string|null $bundleDir The bundle directory path
455
+ *
443
456
* @return string
444
457
*/
445
- abstract protected function getMappingResourceConfigDirectory ();
458
+ abstract protected function getMappingResourceConfigDirectory (/*string $bundleDir = null*/ );
446
459
447
460
/**
448
461
* Extension used by the mapping files.
0 commit comments