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 df343d0
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/Doctrine/UserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
use Doctrine\ODM\MongoDB\DocumentManager;
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;
use Nucleos\UserBundle\Model\UserInterface;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
Expand All @@ -36,28 +37,24 @@ public function __construct(UserPasswordHasherInterface $userPasswordHasher)
public function getSubscribedEvents(): array
{
return [
'prePersist',
'preUpdate',
Events::prePersist,
Events::preUpdate,
];
}

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

if ($object instanceof UserInterface) {
$this->updateUserFields($object);
}
}

/**
* @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 df343d0

Please sign in to comment.