Skip to content

Commit

Permalink
Merge pull request #32 from pauci/feature/doctrine-deprecations
Browse files Browse the repository at this point in the history
fix: Do not use deprecated doctrine classes and methods
  • Loading branch information
pauci authored Aug 5, 2024
2 parents 58dcd30 + 3eccb66 commit 65beb7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/Plugin/Doctrine/EventHandling/Publisher/DoctrineIdentityMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
use CQRS\Domain\Model\AggregateRootInterface;
use CQRS\EventHandling\Publisher\SimpleIdentityMap;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\OnClearEventArgs;
use Doctrine\ORM\Event\PostLoadEventArgs;
use Doctrine\ORM\Event\PrePersistEventArgs;
use Doctrine\ORM\Event\PreRemoveEventArgs;
use Doctrine\ORM\Events;

class DoctrineIdentityMap extends SimpleIdentityMap implements EventSubscriber
Expand All @@ -23,27 +25,27 @@ public function getSubscribedEvents(): array
];
}

public function postLoad(LifecycleEventArgs $args): void
public function postLoad(PostLoadEventArgs $args): void
{
$entity = $args->getEntity();
$entity = $args->getObject();

if ($entity instanceof AggregateRootInterface) {
$this->add($entity);
}
}

public function prePersist(LifecycleEventArgs $args): void
public function prePersist(PrePersistEventArgs $args): void
{
$entity = $args->getEntity();
$entity = $args->getObject();

if ($entity instanceof AggregateRootInterface) {
$this->add($entity);
}
}

public function preRemove(LifecycleEventArgs $args): void
public function preRemove(PreRemoveEventArgs $args): void
{
$entity = $args->getEntity();
$entity = $args->getObject();

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

public function onClear(OnClearEventArgs $args): void
{
if ($args->clearsAllEntities()) {
$this->clear();
}
$this->clear();
}
}
2 changes: 1 addition & 1 deletion tests/Plugin/Doctrine/EventStore/TableEventStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function setUp(): void
'memory' => true,
]);

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

$listener = new CreateEventStoreTableListener();
$em->getEventManager()->addEventSubscriber($listener);
Expand Down

0 comments on commit 65beb7a

Please sign in to comment.