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\Owner;
|
||||||
use App\Entity\Poll;
|
use App\Entity\Poll;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Exception;
|
||||||
|
use Swift_Mailer;
|
||||||
use Swift_Message;
|
use Swift_Message;
|
||||||
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
||||||
use Symfony\Component\Mime\Address;
|
use Symfony\Component\Mime\Address;
|
||||||
|
use Symfony\Component\Mime\Email;
|
||||||
|
|
||||||
class MailService {
|
class MailService {
|
||||||
|
|
||||||
@ -19,16 +22,16 @@ class MailService {
|
|||||||
*/
|
*/
|
||||||
private $em;
|
private $em;
|
||||||
/**
|
/**
|
||||||
* @var \Swift_Mailer
|
* @var Swift_Mailer
|
||||||
*/
|
*/
|
||||||
private $mailer;
|
private $mailer;
|
||||||
|
|
||||||
public function __construct( EntityManagerInterface $entityManager, \Swift_Mailer $mailer ) {
|
public function __construct( EntityManagerInterface $entityManager, Swift_Mailer $mailer ) {
|
||||||
$this->em = $entityManager;
|
$this->em = $entityManager;
|
||||||
$this->mailer = $mailer;
|
$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 );
|
$em = $this->em->getRepository( Owner::class );
|
||||||
$admin_user = $foundOwner;
|
$admin_user = $foundOwner;
|
||||||
$poll = $newpoll;
|
$poll = $newpoll;
|
||||||
@ -43,16 +46,17 @@ class MailService {
|
|||||||
'email_template' => 'emails/creation-mail.html.twig',
|
'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' )
|
->setFrom( 'ne-pas-repondre@framadate-api.cipherbliss.com' )
|
||||||
->setContentType( 'text/html' )
|
->setContentType( 'text/html' )
|
||||||
->setCharset( 'UTF-8' )
|
->setCharset( 'UTF-8' )
|
||||||
|
->subject('Framadate - mes sondages')
|
||||||
->setTo( $admin_user->getEmail() )
|
->setTo( $admin_user->getEmail() )
|
||||||
->htmlTemplate( $templateVars[ 'email_template' ] )
|
->htmlTemplate( $templateVars[ 'email_template' ] )
|
||||||
->context( $templateVars );
|
->context( $templateVars );
|
||||||
|
|
||||||
// send email
|
// send email
|
||||||
return $mailer->send( $message );
|
return $mailer->send( $email );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +66,7 @@ class MailService {
|
|||||||
* @param Owner $foundOwner
|
* @param Owner $foundOwner
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function sendOwnerPollsAction( Owner $foundOwner ) {
|
public function sendOwnerPollsAction( Owner $foundOwner ) {
|
||||||
$em = $this->em->getRepository( Owner::class );
|
$em = $this->em->getRepository( Owner::class );
|
||||||
@ -85,7 +89,7 @@ class MailService {
|
|||||||
$templateVars = [
|
$templateVars = [
|
||||||
'owner' => $admin_user,
|
'owner' => $admin_user,
|
||||||
'title' => $titleEmail,
|
'title' => $titleEmail,
|
||||||
'email_template' => 'emails/owner-polls.html.twig',
|
'email_template' => 'emails/owner-list.html.twig',
|
||||||
];
|
];
|
||||||
|
|
||||||
$email = ( new TemplatedEmail() )
|
$email = ( new TemplatedEmail() )
|
||||||
|
Loading…
Reference in New Issue
Block a user