src/Controller/Client/Fr/DemandeDeCotationController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Client\Fr;
  3. use App\Entity\DemandeDeCotation;
  4. use App\Form\DemandeDeCotationType;
  5. use App\Repository\DemandeDeCotationRepository;
  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 DemandeDeCotationController extends AbstractController
  11. {
  12.     /**
  13.      * @Route("/demande-de-cotation", name="demande_de_cotation_new", methods={"GET","POST"})
  14.      */
  15.     public function new(Request $request): Response
  16.     {
  17.         $demandeDeCotation = new DemandeDeCotation();
  18.         $form $this->createForm(DemandeDeCotationType::class, $demandeDeCotation);
  19.         $form->handleRequest($request);
  20.         if ($form->isSubmitted() && $form->isValid()) {
  21.             $entityManager $this->getDoctrine()->getManager();
  22.             $entityManager->persist($demandeDeCotation);
  23.             $entityManager->flush();
  24.             $this->addFlash('success',"Votre demande de cotation a été transmise avec succès.");
  25.             return $this->redirectToRoute('demande_de_cotation_new');
  26.         }
  27.         return $this->render('client/fr/demande_de_cotation/new.html.twig', [
  28.             'demande_de_cotation' => $demandeDeCotation,
  29.             'form' => $form->createView(),
  30.         ]);
  31.     }
  32. }