Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fa2f0be

Browse filesBrowse files
[DoctrineBridge] fix setting default mapping type to attribute/annotation on php 8/7 respectively
1 parent 120f3d6 commit fa2f0be
Copy full SHA for fa2f0be

File tree

1 file changed

+21
-0
lines changed
Filter options

1 file changed

+21
-0
lines changed

‎src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Doctrine\DependencyInjection;
1313

14+
use Symfony\Component\Config\Resource\GlobResource;
1415
use Symfony\Component\DependencyInjection\Alias;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Definition;
@@ -88,6 +89,26 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
8889
if (!$mappingConfig) {
8990
continue;
9091
}
92+
} elseif (!$mappingConfig['type']) {
93+
if (\PHP_VERSION_ID >= 80000) {
94+
$mappingConfig['type'] = 'attribute';
95+
$glob = new GlobResource($mappingConfig['dir'], '*', true);
96+
$container->addResource($glob);
97+
98+
foreach ($glob as $file) {
99+
$content = file_get_contents($file);
100+
101+
if (preg_match('/^#\[.*Entity\b/m', $content)) {
102+
break;
103+
}
104+
if (preg_match('/^ \* @.*Entity\b/m', $content)) {
105+
$mappingConfig['type'] = 'annotation';
106+
break;
107+
}
108+
}
109+
} else {
110+
$mappingConfig['type'] = 'annotation';
111+
}
91112
}
92113

93114
$this->assertValidMappingConfiguration($mappingConfig, $objectManager['name']);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.