fix(continuous-integration): correction php-cs-fixer
All checks were successful
Cadoles/nineskeletor/pipeline/pr-master This commit looks good

This commit is contained in:
2022-09-23 16:14:15 +02:00
parent 5f3cc51f5c
commit b78f54b76c
70 changed files with 5943 additions and 5549 deletions

View File

@ -1,52 +1,54 @@
<?php
namespace App\Service;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;
class MailService
{
protected $mailer;
protected $twig;
public function __construct(MailerInterface $mailer, \Twig\Environment $twig)
{
$this->mailer = $mailer;
$this->twig = $twig;
}
/**
* Send email
* Send email.
*
* @param string $template email template
* @param mixed $parameters custom params for template
* @param string $to to email address or array of email addresses
* @param string $from from email address
* @param string $fromName from name
* @param string $template email template
* @param mixed $parameters custom params for template
* @param string $to to email address or array of email addresses
* @param string $from from email address
* @param string $fromName from name
*
* @return boolean send status
* @return bool send status
*/
public function sendEmail($subject, $body, $to, $from, $fromName = null)
{
$template = $this->twig->load('Home/mail.html.twig');
$parameters=["subject"=>$subject,"body"=>$body];
$subject = $template->renderBlock('subject', $parameters);
$bodyHtml = $template->renderBlock('body', $parameters);
try {
if(!is_array($to)) $to=[$to];
foreach($to as $t) {
$parameters = ['subject' => $subject, 'body' => $body];
$subject = $template->renderBlock('subject', $parameters);
$bodyHtml = $template->renderBlock('body', $parameters);
try {
if (!is_array($to)) {
$to = [$to];
}
foreach ($to as $t) {
$message = (new Email())
->subject($subject)
->from(Address::create($fromName. "<".$from.">"))
->from(Address::create($fromName.'<'.$from.'>'))
->to($t)
->html($bodyHtml);
$this->mailer->send($message);
}
} catch (TransportExceptionInterface $e) {
return $e->getMessage();
@ -54,4 +56,4 @@ class MailService
return true;
}
}
}