Skip to content

Commit d830ad5

Browse files
committed
Add support for doctrine/orm v3
1 parent 4423c17 commit d830ad5

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

CHANGELOG-5.x.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
5.1.0
2+
-----
3+
4+
* Add support for doctrine/orm v3
5+
16
5.0.0
27
-----
38

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"require": {
2828
"php": "^8.2",
2929
"ext-curl": "*",
30-
"doctrine/orm": "^2.5",
30+
"doctrine/orm": "^2.5 || ^3.0",
3131
"leapt/core-bundle": "^5.0",
3232
"symfony/css-selector": "^6.4 || ^7.0",
3333
"symfony/console": "^6.4 || ^7.0",

src/Listener/MogrifySubscriber.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,22 @@ private function checkClassConfig(object $entity, EntityManagerInterface $entity
6464
if (!\array_key_exists($class, $this->config)) {
6565
$meta = $entityManager->getClassMetaData($class);
6666

67-
foreach ($meta->getReflectionClass()->getProperties() as $property) {
68-
if ($meta->isMappedSuperclass && !$property->isPrivate()
69-
|| $meta->isInheritedField($property->name)
70-
|| isset($meta->associationMappings[$property->name]['inherited'])
71-
) {
72-
continue;
73-
}
74-
$attributes = $this->getAttributes($property);
75-
foreach ($attributes as $attribute) {
76-
$field = $property->getName();
77-
$this->config[$class]['fields'][$field] = [
78-
'property' => $property,
79-
'params' => $attribute->params,
80-
];
67+
foreach ($meta->getReflectionProperties() as $property) {
68+
if (null !== $property) {
69+
if ($meta->isMappedSuperclass && !$property->isPrivate()
70+
|| $meta->isInheritedField($property->name)
71+
|| isset($meta->associationMappings[$property->name]['inherited'])
72+
) {
73+
continue;
74+
}
75+
$attributes = $this->getAttributes($property);
76+
foreach ($attributes as $attribute) {
77+
$field = $property->getName();
78+
$this->config[$class]['fields'][$field] = [
79+
'property' => $property,
80+
'params' => $attribute->params,
81+
];
82+
}
8183
}
8284
}
8385
}

tests/Listener/MogrifySubscriberTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testPrePersist(): void
5252

5353
private function buildEntityManager(): EntityManagerInterface
5454
{
55-
$config = ORMSetup::createConfiguration(false, sys_get_temp_dir());
55+
$config = ORMSetup::createConfiguration(true, sys_get_temp_dir());
5656
$config->setMetadataDriverImpl(new AttributeDriver([__DIR__ . '/Fixtures']));
5757
$config->setAutoGenerateProxyClasses(true);
5858

0 commit comments

Comments
 (0)