<?php
namespace App\Controller;
use App\Entity\PointEaux;
use App\Form\PointEauxType;
use App\Repository\PointEauxRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/point/eaux")
*/
class PointEauxController extends AbstractController
{
/**
* @Route("/", name="point_eaux_index", methods={"GET"})
*/
public function index(PointEauxRepository $pointEauxRepository): Response
{
return $this->render('point_eaux/index.html.twig', [
'point_eauxes' => $pointEauxRepository->findAll(),
]);
}
/**
* @Route("/new", name="point_eaux_new", methods={"GET","POST"})
*/
public function new(Request $request): Response
{
$pointEaux = new PointEaux();
$form = $this->createForm(PointEauxType::class, $pointEaux);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($pointEaux);
$entityManager->flush();
return $this->redirectToRoute('point_eaux_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('point_eaux/new.html.twig', [
'point_eaux' => $pointEaux,
'form' => $form,
]);
}
/**
* @Route("/{id}", name="point_eaux_show", methods={"GET"})
*/
public function show(PointEaux $pointEaux): Response
{
return $this->render('point_eaux/show.html.twig', [
'point_eaux' => $pointEaux,
]);
}
/**
* @Route("/{id}/edit", name="point_eaux_edit", methods={"GET","POST"})
*/
public function edit(Request $request, PointEaux $pointEaux): Response
{
$form = $this->createForm(PointEauxType::class, $pointEaux);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('point_eaux_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('point_eaux/edit.html.twig', [
'point_eaux' => $pointEaux,
'form' => $form,
]);
}
/**
* @Route("/{id}", name="point_eaux_delete", methods={"POST"})
*/
public function delete(Request $request, PointEaux $pointEaux): Response
{
if ($this->isCsrfTokenValid('delete'.$pointEaux->getId(), $request->request->get('_token'))) {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->remove($pointEaux);
$entityManager->flush();
}
return $this->redirectToRoute('point_eaux_index', [], Response::HTTP_SEE_OTHER);
}
}