Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use App\Repository\ChapterRepository;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;

class HomeController extends AbstractController
class MainController extends AbstractController
{
#[Route('/', name: 'app_home')]
public function index(ChapterRepository $chapterRepository): Response
Expand All @@ -32,4 +35,23 @@ public function faq(): Response
{
return $this->render('home/faq.html.twig');
}

#[Route('/contact', name: 'app_contact')]
public function contact(): Response
{
return $this->render('home/contact.html.twig');
}

#[Route('/contact/email', name: 'app_contact_email', methods: ['POST'])]
public function sendEmail(MailerInterface $mailer, Request $request): Response
{
$email = (new Email())
->from($request->request->get('email'))
->to('admin@boulot.fr')
->subject('Email')
->text($request->request->get('content'));

$mailer->send($email);
return $this->redirectToRoute('app_home');
}
}
3 changes: 3 additions & 0 deletions templates/_navbar.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<li class="faq">
<a href={{ path('app_faq') }}>FAQ</a>
</li>
<li class="contact">
<a href={{ path('app_contact') }}>Contact</a>
</li>
{% if app.user %}
<li class="profile">
<a href={{ path('app_my_profile') }}> Mon compte</a>
Expand Down
22 changes: 22 additions & 0 deletions templates/home/contact.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends 'base.html.twig' %}

{% block title %}Contact{% endblock %}

{% block main %}
<article>
<h1>Contact</h1>
<form class="centerForm" action="{{path('app_contact_email')}}" method="POST">
<div>
<label for="email" >Email</label>
<input type="email" name="email" id="email" value="">
</div>
<div>
<label for="content">Contenu</label>
<textarea rows=10 cols=60 name="content" id="content" value=""></textarea>
</div>
<div>
<button type="submit" class="btn">Envoyer</button>
</div>
Comment on lines +17 to +19

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Précise explicitement le type submit sur le bouton

</form>
</article>
{% endblock %}
2 changes: 1 addition & 1 deletion templates/home/faq.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
{% endblock %}
{% block qFooter %}
<footer class="qFooter">
<p>Vous n'avez pas votre réponse? <a href="">Posez votre question ici</a></p>
<p>Vous n'avez pas votre réponse? <a href="{{path('app_contact')}}">Posez votre question ici</a></p>
</footer>
{% endblock %}