<?php
namespace App\Controller;
use App\Entity\Planning;
use App\Form\ContactFormType;
use App\Repository\PlanningRepository;
use App\Service\EmailService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController ;
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends AbstractController {
function index(Request $request, EmailService $emailService, PlanningRepository $pRepo) {
$form = $this->createForm(ContactFormType::class);
$planning = $pRepo->find(1);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$emailService->sendContact($data);
}
return $this->render('home.html.twig', [
'form' => $form->createView(),
'planning' => $planning
]);
}
}