Skip to content

Commit 024b1c9

Browse files
committed
Allow autodetecting mapping type for any object
1 parent 4dfecea commit 024b1c9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,15 @@ private function detectMappingType(string $directory, ContainerBuilder $containe
290290
$glob = new GlobResource($directory, '*', true);
291291
$container->addResource($glob);
292292

293+
$quotedMappingObjectName = preg_quote($this->getMappingObjectDefaultName(), '/');
294+
293295
foreach ($glob as $file) {
294296
$content = file_get_contents($file);
295297

296-
if (preg_match('/^#\[.*Entity\b/m', $content)) {
298+
if (preg_match('/^#\[.*'.$quotedMappingObjectName.'\b/m', $content)) {
297299
break;
298300
}
299-
if (preg_match('/^ \* @.*Entity\b/m', $content)) {
301+
if (preg_match('/^ \* @.*'.$quotedMappingObjectName.'\b/m', $content)) {
300302
$type = 'annotation';
301303
break;
302304
}

Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ protected function setUp(): void
4949
->willReturnCallback(function ($name) {
5050
return 'doctrine.orm.'.$name;
5151
});
52+
53+
$this->extension
54+
->method('getMappingObjectDefaultName')
55+
->willReturn('Entity');
5256
}
5357

5458
public function testFixManagersAutoMappingsWithTwoAutomappings()

0 commit comments

Comments
 (0)