<?php
namespace App\EventListener;
use App\Event\AppEvent;
class AuthMailer extends AbstractMailer
{
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return [
AppEvent::FORGET_PASSWORD => 'onForgetPassword',
];
}
public function onForgetPassword(AppEvent $event)
{
$user = $event->getUser();
$user->setConfirmationToken(base_convert(sha1(uniqid(mt_rand(), true)), 16, 36));
$user->setPasswordRequestedAt(new \DateTime());
$this->em->persist($user);
$this->em->flush();
$this->mailer->sendEventMail($event, AppEvent::FORGET_PASSWORD);
}
}