Skip to content

Commit

Permalink
Remove doctrine deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Aug 2, 2023
1 parent e29e869 commit ee890bf
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Doctrine/UserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata as MongoClassMetadata;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Event\PrePersistEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\Events;
use Doctrine\ORM\Mapping\ClassMetadata as ORMClassMetadata;
use Doctrine\Persistence\Event\LifecycleEventArgs;
use Doctrine\Persistence\ObjectManager;
Expand All @@ -36,17 +39,18 @@ public function __construct(UserPasswordHasherInterface $userPasswordHasher)
public function getSubscribedEvents(): array
{
return [
'prePersist',
'preUpdate',
Events::prePersist,
Events::preUpdate,
];
}

/**
* @psalm-param LifecycleEventArgs<EntityManagerInterface> $args
* @psalm-param PrePersistEventArgs<EntityManagerInterface> $args
*/
public function prePersist(LifecycleEventArgs $args): void
public function prePersist(PrePersistEventArgs $args): void
{
$object = $args->getObject();

if ($object instanceof UserInterface) {
$this->updateUserFields($object);
}
Expand All @@ -55,9 +59,10 @@ public function prePersist(LifecycleEventArgs $args): void
/**
* @psalm-param LifecycleEventArgs<EntityManagerInterface> $args
*/
public function preUpdate(LifecycleEventArgs $args): void
public function preUpdate(PreUpdateEventArgs $args): void
{
$object = $args->getObject();

if ($object instanceof UserInterface) {
$this->updateUserFields($object);
$this->recomputeChangeSet($args->getObjectManager(), $object);
Expand Down

0 comments on commit ee890bf

Please sign in to comment.