src/Controller/DefaultController.php line 16

  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Fap;
  4. use App\Form\FapType;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class DefaultController extends AbstractController
  11. {
  12.     #[Route('/'name'homepage')]
  13.     public function index(Request $requestEntityManagerInterface $entityManager): Response
  14.     {
  15.         $fap = new Fap();
  16.         $form $this->createForm(FapType::class, $fap);
  17.         $form->handleRequest($request);
  18.         if ($form->isSubmitted()){
  19.             if ($form->isValid()) {
  20.                 $entityManager->persist($fap);
  21.                 $entityManager->flush();
  22.                 $fap = new Fap();
  23.                 $form $this->createForm(FapType::class, $fap);
  24.                 $this->addFlash('success''FAAAAAPULOUS, we\'re gonna check this gift');
  25.             }
  26.             else {
  27.                 $this->addFlash('error''An error happened. It could be the file size. The system allows until 2 Mo');
  28.             }
  29.         }
  30.         return $this->render('default/index.html.twig', [
  31.             'form' => $form->createView(),
  32.         ]);
  33.     }
  34. }