From badab8fe84b4aa52c0fe08bbb39ace1213630918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mike=C5=A1?= Date: Mon, 22 Jan 2024 20:37:29 +0100 Subject: [PATCH] Reset EntityManager via reinitialization, instead of removing from container --- src/ManagerRegistry.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ManagerRegistry.php b/src/ManagerRegistry.php index 0493181..28bda51 100644 --- a/src/ManagerRegistry.php +++ b/src/ManagerRegistry.php @@ -63,7 +63,10 @@ protected function getService(string $name) */ protected function resetService(string $name): void { - $this->container->removeService($name); + /** @var EntityManagerDecorator $manager */ + $manager = $this->container->getService($name); + $wrapped = $this->container->createInstance(\Doctrine\ORM\EntityManager::class); + $manager->__construct($wrapped); } }