|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Service;
|
|
|
|
|
|
+use App\Entity\User;
|
|
|
use Symfony\Component\Mailer\MailerInterface;
|
|
|
use Symfony\Component\Mime\Address;
|
|
|
use Symfony\Component\Mime\Email;
|
|
@@ -31,7 +32,7 @@ class Mail
|
|
|
|
|
|
}
|
|
|
|
|
|
- protected function sendMessage($subject, $to, $body): void
|
|
|
+ protected function sendMessage(string $subject, string $to, string $body): void
|
|
|
{
|
|
|
$mail = (new Email())
|
|
|
->from(new Address($this->from, $this->name))
|
|
@@ -43,21 +44,30 @@ class Mail
|
|
|
$this->mailer->send($mail);
|
|
|
}
|
|
|
|
|
|
- public function sendMailActivation(\App\Entity\User $user, $lien): void
|
|
|
+ public function sendMailActivation(User $user, string $lien): void
|
|
|
{
|
|
|
$subject = "Activation de votre compte";
|
|
|
$template = 'security/mail_activate.html.twig';
|
|
|
$to = $user->getMail();
|
|
|
- $body = $this->templating->render($template, array('user' => $user, 'lien' => $lien));
|
|
|
+ $body = $this->templating->render($template, ['user' => $user, 'lien' => $lien]);
|
|
|
$this->sendMessage($subject, $to, $body);
|
|
|
}
|
|
|
|
|
|
- public function sendMailTokenMp(\App\Entity\User $user, $lien): void
|
|
|
+ public function sendMailDemandeActivation(User $user, string $lien): void
|
|
|
+ {
|
|
|
+ $subject = "Demande d'activation";
|
|
|
+ $template = 'security/mail_demande_activation.html.twig';
|
|
|
+ $to = $this->from;
|
|
|
+ $body = $this->templating->render($template, ['user' => $user, 'lien' => $lien]);
|
|
|
+ $this->sendMessage($subject, $to, $body);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function sendMailTokenMp(User $user, string $lien): void
|
|
|
{
|
|
|
$subject = "Mot de passe perdu";
|
|
|
$template = 'security/mail_tokenmdp.html.twig';
|
|
|
$to = $user->getMail();
|
|
|
- $body = $this->templating->render($template, array('user' => $user, 'lien' => $lien));
|
|
|
+ $body = $this->templating->render($template, ['user' => $user, 'lien' => $lien]);
|
|
|
$this->sendMessage($subject, $to, $body);
|
|
|
}
|
|
|
}
|