src/Controller/DefaultController.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Planning;
  4. use App\Form\ContactFormType;
  5. use App\Repository\PlanningRepository;
  6. use App\Service\EmailService;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController ;
  8. use Symfony\Component\HttpFoundation\Request;
  9. class DefaultController extends AbstractController  {
  10.     function index(Request $requestEmailService $emailServicePlanningRepository $pRepo) {
  11.         $form $this->createForm(ContactFormType::class);
  12.         $planning $pRepo->find(1);
  13.         $form->handleRequest($request);
  14.         if ($form->isSubmitted() && $form->isValid()) {
  15.             $data $form->getData();
  16.             $emailService->sendContact($data);
  17.         }
  18.         return $this->render('home.html.twig', [
  19.             'form' => $form->createView(),
  20.             'planning' => $planning
  21.         ]);
  22.     }
  23. }