src/Controller/PointEauxController.php line 54

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\PointEaux;
  4. use App\Form\PointEauxType;
  5. use App\Repository\PointEauxRepository;
  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. /**
  11.  * @Route("/point/eaux")
  12.  */
  13. class PointEauxController extends AbstractController
  14. {
  15.     /**
  16.      * @Route("/", name="point_eaux_index", methods={"GET"})
  17.      */
  18.     public function index(PointEauxRepository $pointEauxRepository): Response
  19.     {
  20.         return $this->render('point_eaux/index.html.twig', [
  21.             'point_eauxes' => $pointEauxRepository->findAll(),
  22.         ]);
  23.     }
  24.     /**
  25.      * @Route("/new", name="point_eaux_new", methods={"GET","POST"})
  26.      */
  27.     public function new(Request $request): Response
  28.     {
  29.         $pointEaux = new PointEaux();
  30.         $form $this->createForm(PointEauxType::class, $pointEaux);
  31.         $form->handleRequest($request);
  32.         if ($form->isSubmitted() && $form->isValid()) {
  33.             $entityManager $this->getDoctrine()->getManager();
  34.             $entityManager->persist($pointEaux);
  35.             $entityManager->flush();
  36.             return $this->redirectToRoute('point_eaux_index', [], Response::HTTP_SEE_OTHER);
  37.         }
  38.         return $this->renderForm('point_eaux/new.html.twig', [
  39.             'point_eaux' => $pointEaux,
  40.             'form' => $form,
  41.         ]);
  42.     }
  43.     /**
  44.      * @Route("/{id}", name="point_eaux_show", methods={"GET"})
  45.      */
  46.     public function show(PointEaux $pointEaux): Response
  47.     {
  48.         return $this->render('point_eaux/show.html.twig', [
  49.             'point_eaux' => $pointEaux,
  50.         ]);
  51.     }
  52.     /**
  53.      * @Route("/{id}/edit", name="point_eaux_edit", methods={"GET","POST"})
  54.      */
  55.     public function edit(Request $requestPointEaux $pointEaux): Response
  56.     {
  57.         $form $this->createForm(PointEauxType::class, $pointEaux);
  58.         $form->handleRequest($request);
  59.         if ($form->isSubmitted() && $form->isValid()) {
  60.             $this->getDoctrine()->getManager()->flush();
  61.             return $this->redirectToRoute('point_eaux_index', [], Response::HTTP_SEE_OTHER);
  62.         }
  63.         return $this->renderForm('point_eaux/edit.html.twig', [
  64.             'point_eaux' => $pointEaux,
  65.             'form' => $form,
  66.         ]);
  67.     }
  68.     /**
  69.      * @Route("/{id}", name="point_eaux_delete", methods={"POST"})
  70.      */
  71.     public function delete(Request $requestPointEaux $pointEaux): Response
  72.     {
  73.         if ($this->isCsrfTokenValid('delete'.$pointEaux->getId(), $request->request->get('_token'))) {
  74.             $entityManager $this->getDoctrine()->getManager();
  75.             $entityManager->remove($pointEaux);
  76.             $entityManager->flush();
  77.         }
  78.         return $this->redirectToRoute('point_eaux_index', [], Response::HTTP_SEE_OTHER);
  79.     }
  80. }