-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5aaa9d8
commit 04a1d76
Showing
243 changed files
with
162 additions
and
45,438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
namespace App\Controller; | ||
|
||
use App\Form\Type\ContactType; | ||
use App\Service\Mailer; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
@@ -13,15 +14,18 @@ class DefaultControler extends AbstractController | |
{ | ||
/** | ||
* @Route("/", name="index") | ||
* | ||
* @param Request $request | ||
* @param Mailer $mailer | ||
* @return Response | ||
*/ | ||
public function index(Request $request, \Swift_Mailer $mailer): Response | ||
public function index(Request $request, Mailer $mailer): Response | ||
{ | ||
$form = $this->createForm(ContactType::class, null); | ||
$form->handleRequest($request); | ||
|
||
if ($form->isSubmitted() && $form->isValid()) { | ||
$data = $form->getData(); | ||
if($this->sendEmail($data, $mailer)) { | ||
if($mailer->sendEmail($form->getData())) { | ||
$this->addFlash('contact', 'Votre email a été envoyé et sera traité dans les meilleurs délais.'); | ||
} else { | ||
$this->addFlash('echec', 'Un problème a eu lieu durant l\'envoie, veuillez ré-essayer plus tard'); | ||
|
@@ -32,35 +36,4 @@ public function index(Request $request, \Swift_Mailer $mailer): Response | |
'form' => $form->createView(), | ||
]); | ||
} | ||
|
||
/** | ||
* @param $data | ||
* @param \Swift_Mailer $mailer | ||
* | ||
* @return bool | ||
* @todo New service for that | ||
*/ | ||
private function sendEmail($data, \Swift_Mailer $mailer) | ||
{ | ||
$mail = new \Swift_Message(); | ||
-> setSubject($data['objet']) | ||
-> setFrom($data['email']) | ||
-> setTo('[email protected]') | ||
-> setBody( | ||
$this -> renderView('emails/contact.html.twig', [ | ||
'data' => $data | ||
]), 'text/html' | ||
) | ||
; | ||
|
||
if($mailer -> send($mail)) | ||
{ | ||
return true; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,41 +3,44 @@ | |
|
||
namespace App\Service; | ||
|
||
use Twig\Environment; | ||
|
||
class Mailer | ||
{ | ||
public function __construct() | ||
{ | ||
/** @var Environment */ | ||
private $twig; | ||
|
||
/** @var \Swift_Mailer */ | ||
private $mailer; | ||
|
||
public function __construct(Environment $twig, \Swift_Mailer $mailer) | ||
{ | ||
$this->twig = $twig; | ||
$this->mailer = $mailer; | ||
} | ||
|
||
/** | ||
* @param $data | ||
* @param \Swift_Mailer $mailer | ||
* | ||
* @param $data | ||
* @return bool | ||
* @todo New service for that | ||
*/ | ||
private function sendEmail($data, \Swift_Mailer $mailer) | ||
public function sendEmail($data) | ||
{ | ||
$mail = new \Swift_Message(); | ||
-> setSubject($data['objet']) | ||
-> setFrom($data['email']) | ||
-> setTo('[email protected]') | ||
-> setBody( | ||
$this->renderView('emails/contact.html.twig', [ | ||
->setSubject($data['objet']) | ||
->setFrom($data['email']) | ||
->setTo('[email protected]') | ||
->setBody( | ||
$this->twig->render('emails/contact.html.twig', [ | ||
'data' => $data | ||
]), 'text/html' | ||
) | ||
; | ||
|
||
if($mailer -> send($mail)) | ||
{ | ||
return true; | ||
} | ||
else | ||
{ | ||
if (0 === $this->mailer->send($mail)){ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{# Rows #} | ||
{% block form_row -%} | ||
{%- set widget_attr = {} -%} | ||
{%- if help is not empty -%} | ||
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%} | ||
{%- endif -%} | ||
<div{% with {attr: row_attr|merge({class: (row_attr.class|default('') ~ ' input-field' ~ ((not compound or force_error|default(false)) and not valid ? ' is-invalid'))|trim})} %}{{ block('attributes') }}{% endwith %}> | ||
{{- form_widget(form, widget_attr) -}} | ||
{{- form_help(form) -}} | ||
{{- form_label(form) -}} | ||
</div> | ||
{%- endblock form_row %} | ||
|
||
{% block submit_row -%} | ||
{%- set widget_attr = {attr: {'class': 'btn dark-bg waves-effect'}} -%} | ||
{{- form_widget(form, widget_attr) -}} | ||
{%- endblock submit_row %} | ||
|
||
{# Widgets #} | ||
|
||
{% block textarea_widget -%} | ||
{% set attr = attr|merge({class: (attr.class|default('') ~ ' materialize-textarea')|trim}) %} | ||
<textarea {{ block('widget_attributes') }}>{{ value }}</textarea> | ||
{%- endblock textarea_widget %} | ||
|
||
{# | ||
div class input-field | ||
textarea class materialize-textarea | ||
input class validate | ||
submit btn | ||
<i class="btn dark-bg waves-effect waves-input-wrapper" style=""><input type="submit" class="waves-button-input" value="ENVOYER"></i> | ||
#} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.