src/EventListener/AuthMailer.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use App\Event\AppEvent;
  4. class AuthMailer extends AbstractMailer
  5. {
  6.     /**
  7.      * {@inheritDoc}
  8.      */
  9.     public static function getSubscribedEvents()
  10.     {
  11.         return [
  12.             AppEvent::FORGET_PASSWORD => 'onForgetPassword',
  13.         ];
  14.     }
  15.     public function onForgetPassword(AppEvent $event)
  16.     {
  17.         $user $event->getUser();
  18.         $user->setConfirmationToken(base_convert(sha1(uniqid(mt_rand(), true)), 1636));
  19.         $user->setPasswordRequestedAt(new \DateTime());
  20.         $this->em->persist($user);
  21.         $this->em->flush();
  22.         $this->mailer->sendEventMail($eventAppEvent::FORGET_PASSWORD);
  23.     }
  24. }