mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
more testing
This commit is contained in:
parent
00fe90b66b
commit
ac09cab3a0
@ -7,9 +7,12 @@ namespace App\Service;
|
||||
use App\Entity\Owner;
|
||||
use App\Entity\Poll;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exception;
|
||||
use Swift_Mailer;
|
||||
use Swift_Message;
|
||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||
use Symfony\Component\Mime\Address;
|
||||
use Symfony\Component\Mime\Email;
|
||||
|
||||
class MailService {
|
||||
|
||||
@ -19,16 +22,16 @@ class MailService {
|
||||
*/
|
||||
private $em;
|
||||
/**
|
||||
* @var \Swift_Mailer
|
||||
* @var Swift_Mailer
|
||||
*/
|
||||
private $mailer;
|
||||
|
||||
public function __construct( EntityManagerInterface $entityManager, \Swift_Mailer $mailer ) {
|
||||
public function __construct( EntityManagerInterface $entityManager, Swift_Mailer $mailer ) {
|
||||
$this->em = $entityManager;
|
||||
$this->mailer = $mailer;
|
||||
}
|
||||
|
||||
public function sendCreationMailAction( Owner $foundOwner, Poll $newpoll, \Swift_Mailer $mailer ) {
|
||||
public function sendCreationMailAction( Owner $foundOwner, Poll $newpoll, Swift_Mailer $mailer ) {
|
||||
$em = $this->em->getRepository( Owner::class );
|
||||
$admin_user = $foundOwner;
|
||||
$poll = $newpoll;
|
||||
@ -43,16 +46,17 @@ class MailService {
|
||||
'email_template' => 'emails/creation-mail.html.twig',
|
||||
];
|
||||
|
||||
$message = ( new Swift_Message( 'Framadate - mes sondages' ) )
|
||||
$email = ( new Email( ) )
|
||||
->setFrom( 'ne-pas-repondre@framadate-api.cipherbliss.com' )
|
||||
->setContentType( 'text/html' )
|
||||
->setCharset( 'UTF-8' )
|
||||
->subject('Framadate - mes sondages')
|
||||
->setTo( $admin_user->getEmail() )
|
||||
->htmlTemplate( $templateVars[ 'email_template' ] )
|
||||
->context( $templateVars );
|
||||
|
||||
// send email
|
||||
return $mailer->send( $message );
|
||||
return $mailer->send( $email );
|
||||
|
||||
}
|
||||
|
||||
@ -62,7 +66,7 @@ class MailService {
|
||||
* @param Owner $foundOwner
|
||||
*
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sendOwnerPollsAction( Owner $foundOwner ) {
|
||||
$em = $this->em->getRepository( Owner::class );
|
||||
@ -85,7 +89,7 @@ class MailService {
|
||||
$templateVars = [
|
||||
'owner' => $admin_user,
|
||||
'title' => $titleEmail,
|
||||
'email_template' => 'emails/owner-polls.html.twig',
|
||||
'email_template' => 'emails/owner-list.html.twig',
|
||||
];
|
||||
|
||||
$email = ( new TemplatedEmail() )
|
||||
|
Loading…
Reference in New Issue
Block a user