From 1e9c5074b2e6a3eeb433f7cdc182352232f712fa Mon Sep 17 00:00:00 2001 From: Baptiste Lemoine Date: Sun, 12 Apr 2020 17:35:57 +0200 Subject: [PATCH] :zap: mail service start --- src/Service/MailService.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Service/MailService.php b/src/Service/MailService.php index eb229aa..698b15d 100644 --- a/src/Service/MailService.php +++ b/src/Service/MailService.php @@ -5,14 +5,22 @@ namespace App\Service; use App\Entity\Owner; +use App\Entity\Poll; +use Doctrine\ORM\EntityManager; +use Doctrine\ORM\EntityManagerInterface; +use Swift_Message; class MailService { - public function sendCreationMailAction( $foundOwner, $newpoll, \Swift_Mailer $mailer ) { - $em = $this->getDoctrine()->getRepository( Owner::class ); - $admin_user = $em->find( 1 ); - $poll = $admin_user->getPolls()[ 0 ]; + public function __construct(EntityManagerInterface $entityManager) { + $this->em = $entityManager; + } + + public function sendCreationMailAction( Owner $foundOwner, Poll $newpoll, \Swift_Mailer $mailer ) { + $em = $this->em->getRepository( Owner::class ); + $admin_user = $foundOwner; + $poll = $newpoll; // anti spam , limit to every minute @@ -30,7 +38,6 @@ class MailService { $templateVars = [ 'owner' => $admin_user, 'poll' => $poll, - 'url' => $poll->getCustomUrl(), 'title' => 'Création de sondage - ' . $poll->getTitle(), 'email_template' => 'emails/creation-mail.html.twig', ];