13
13
14
14
use Doctrine \DBAL \Connection ;
15
15
use Doctrine \ORM \EntityManagerInterface ;
16
- use Doctrine \ORM \Mapping \Driver \AnnotationDriver ;
17
16
use Doctrine \ORM \Mapping \Driver \AttributeDriver ;
18
17
use Doctrine \ORM \Mapping \MappingException as ORMMappingException ;
19
18
use Doctrine \ORM \Mapping \NamingStrategy ;
@@ -147,18 +146,14 @@ public function getEntitiesForAutocomplete(): array
147
146
148
147
public function getMetadata (string $ classOrNamespace = null , bool $ disconnected = false ): array |ClassMetadata
149
148
{
150
- // Invalidating the cached AnnotationDriver ::$classNames to find new Entity classes
149
+ // Invalidating the cached AttributeDriver ::$classNames to find new Entity classes
151
150
foreach ($ this ->mappingDriversByPrefix ?? [] as $ managerName => $ prefixes ) {
152
- foreach ($ prefixes as [$ prefix , $ annotationDriver ]) {
153
- if (null !== $ annotationDriver ) {
154
- if ($ annotationDriver instanceof AnnotationDriver) {
155
- $ classNames = (new \ReflectionClass (AnnotationDriver::class))->getProperty ('classNames ' );
156
- } else {
157
- $ classNames = (new \ReflectionClass (AttributeDriver::class))->getProperty ('classNames ' );
158
- }
151
+ foreach ($ prefixes as [$ prefix , $ attributeDriver ]) {
152
+ if ($ attributeDriver instanceof AttributeDriver) {
153
+ $ classNames = (new \ReflectionClass (AttributeDriver::class))->getProperty ('classNames ' );
159
154
160
155
$ classNames ->setAccessible (true );
161
- $ classNames ->setValue ($ annotationDriver , null );
156
+ $ classNames ->setValue ($ attributeDriver , null );
162
157
}
163
158
}
164
159
}
@@ -184,14 +179,11 @@ public function getMetadata(string $classOrNamespace = null, bool $disconnected
184
179
}
185
180
186
181
if (null === $ this ->mappingDriversByPrefix ) {
187
- // Invalidating the cached AnnotationDriver ::$classNames to find new Entity classes
182
+ // Invalidating the cached AttributeDriver ::$classNames to find new Entity classes
188
183
$ metadataDriver = $ em ->getConfiguration ()->getMetadataDriverImpl ();
184
+
189
185
if ($ this ->isInstanceOf ($ metadataDriver , MappingDriverChain::class)) {
190
186
foreach ($ metadataDriver ->getDrivers () as $ driver ) {
191
- if ($ this ->isInstanceOf ($ driver , AnnotationDriver::class)) {
192
- $ classNames ->setValue ($ driver , null );
193
- }
194
-
195
187
if ($ this ->isInstanceOf ($ driver , AttributeDriver::class)) {
196
188
$ classNames ->setValue ($ driver , null );
197
189
}
0 commit comments