mail service start

This commit is contained in:
Baptiste Lemoine 2020-04-12 17:35:57 +02:00
parent 99f1584d24
commit 1e9c5074b2
1 changed files with 12 additions and 5 deletions

View File

@ -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',
];