Skip to content

Commit 42db917

Browse files
committed
Fix reseting decorated EntityManagers
1 parent 397f207 commit 42db917

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/ManagerRegistry.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Doctrine\ORM\EntityManager;
66
use Doctrine\Persistence\AbstractManagerRegistry;
7+
use Doctrine\Persistence\ObjectManagerDecorator;
78
use Doctrine\Persistence\Proxy;
89
use Nette\DI\Container;
910
use Nettrine\ORM\Utils\Binder;
@@ -45,9 +46,17 @@ protected function resetService(string $name): void
4546
$manager = $this->container->getService($name);
4647

4748
Binder::use($manager, function (): void {
48-
/** @var EntityManager $this */
49-
$this->closed = false; // @phpstan-ignore-line
49+
if ($this instanceof EntityManager) { // @phpstan-ignore-line
50+
$this->closed = false;
51+
} elseif ($this instanceof ObjectManagerDecorator) { // @phpstan-ignore-line
52+
Binder::use($this->wrapped, function (): void {
53+
if ($this instanceof EntityManager) {// @phpstan-ignore-line
54+
$this->closed = false;
55+
}
56+
});
57+
}
5058
});
59+
//throw new \Exception($manager::class);
5160

5261
$this->container->removeService($name);
5362
}

0 commit comments

Comments
 (0)