Skip to content

Commit 3eccb66

Browse files
committed
fix: Do not use deprecated doctrine classes and methods
1 parent 58dcd30 commit 3eccb66

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/Plugin/Doctrine/EventHandling/Publisher/DoctrineIdentityMap.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
use CQRS\Domain\Model\AggregateRootInterface;
88
use CQRS\EventHandling\Publisher\SimpleIdentityMap;
99
use Doctrine\Common\EventSubscriber;
10-
use Doctrine\ORM\Event\LifecycleEventArgs;
1110
use Doctrine\ORM\Event\OnClearEventArgs;
11+
use Doctrine\ORM\Event\PostLoadEventArgs;
12+
use Doctrine\ORM\Event\PrePersistEventArgs;
13+
use Doctrine\ORM\Event\PreRemoveEventArgs;
1214
use Doctrine\ORM\Events;
1315

1416
class DoctrineIdentityMap extends SimpleIdentityMap implements EventSubscriber
@@ -23,27 +25,27 @@ public function getSubscribedEvents(): array
2325
];
2426
}
2527

26-
public function postLoad(LifecycleEventArgs $args): void
28+
public function postLoad(PostLoadEventArgs $args): void
2729
{
28-
$entity = $args->getEntity();
30+
$entity = $args->getObject();
2931

3032
if ($entity instanceof AggregateRootInterface) {
3133
$this->add($entity);
3234
}
3335
}
3436

35-
public function prePersist(LifecycleEventArgs $args): void
37+
public function prePersist(PrePersistEventArgs $args): void
3638
{
37-
$entity = $args->getEntity();
39+
$entity = $args->getObject();
3840

3941
if ($entity instanceof AggregateRootInterface) {
4042
$this->add($entity);
4143
}
4244
}
4345

44-
public function preRemove(LifecycleEventArgs $args): void
46+
public function preRemove(PreRemoveEventArgs $args): void
4547
{
46-
$entity = $args->getEntity();
48+
$entity = $args->getObject();
4749

4850
if ($entity instanceof AggregateRootInterface) {
4951
$this->remove($entity);
@@ -52,8 +54,6 @@ public function preRemove(LifecycleEventArgs $args): void
5254

5355
public function onClear(OnClearEventArgs $args): void
5456
{
55-
if ($args->clearsAllEntities()) {
56-
$this->clear();
57-
}
57+
$this->clear();
5858
}
5959
}

tests/Plugin/Doctrine/EventStore/TableEventStoreTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function setUp(): void
3434
'memory' => true,
3535
]);
3636

37-
$em = EntityManager::create($this->conn, $config);
37+
$em = new EntityManager($this->conn, $config);
3838

3939
$listener = new CreateEventStoreTableListener();
4040
$em->getEventManager()->addEventSubscriber($listener);

0 commit comments

Comments
 (0)