class ResetTokenSender
{
private $mailer;
private $twig;
public function __construct(\Swift_Mailer $mailer, Environment $twig)
{
$this->mailer = $mailer;
$this->twig = $twig;
}
public function send(Email $email, Token $token): void
{
$message = (new \Swift_Message('Password resetting'))
->setTo($email->getValue())
->setBody($this->twig->render('mail/user/reset.html.twig', [
'token' => $token->getToken()
]), 'text/html');
if (!$this->mailer->send($message)) {
throw new \RuntimeException('Unable to send message.');
}
}
}
$user->password = $this->hasher->hash($form->password)
$endWork
.