Skip to content

Commit

Permalink
Support doctrine/persistence 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Feb 1, 2025
1 parent b6048c1 commit 1ce106d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"doctrine/collections": "^1.2 || ^2.0",
"doctrine/deprecations": "^1.0",
"doctrine/event-manager": "^1.2 || ^2.0",
"doctrine/persistence": "^2.2 || ^3.0",
"doctrine/persistence": "^2.2 || ^3.0 || ^4.0",
"psr/cache": "^1 || ^2 || ^3",
"psr/clock": "^1",
"symfony/cache": "^5.4 || ^6.0 || ^7.0"
Expand Down
22 changes: 8 additions & 14 deletions src/References/ReferencesListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,12 @@ public function postLoad(EventArgs $eventArgs)
$property->setValue(
$object,
new LazyCollection(
static function () use ($id, &$manager, $class, $identifier) {
$results = $manager
->getRepository($class)
static fn () => new ArrayCollection(
$manager->getRepository($class)
->findBy([
$identifier => $id,
]);

return new ArrayCollection(is_array($results) ? $results : $results->toArray());
}
])
)
)
);
}
Expand Down Expand Up @@ -235,15 +232,12 @@ public function updateManyEmbedReferences(EventArgs $eventArgs)
$property->setValue(
$object,
new LazyCollection(
static function () use ($id, &$manager, $class, $identifier) {
$results = $manager
->getRepository($class)
static fn () => new ArrayCollection(
$manager->getRepository($class)
->findBy([
$identifier => $id,
]);

return new ArrayCollection(is_array($results) ? $results : $results->toArray());
}
])
)
)
);
}
Expand Down

0 comments on commit 1ce106d

Please sign in to comment.