src/Controller/BlocHeureController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\BlocHeure;
  4. use App\Form\BlocHeureType;
  5. use App\Repository\BlocHeureRepository;
  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. #[Route('/bloc/heure')]
  11. class BlocHeureController extends AbstractController
  12. {
  13.     #[Route('/'name'app_bloc_heure_index'methods: ['GET'])]
  14.     public function index(BlocHeureRepository $blocHeureRepository): Response
  15.     {
  16.         return $this->render('bloc_heure/index.html.twig', [
  17.             'bloc_heures' => $blocHeureRepository->findAll(),
  18.         ]);
  19.     }
  20.     #[Route('/new'name'app_bloc_heure_new'methods: ['GET''POST'])]
  21.     public function new(Request $requestBlocHeureRepository $blocHeureRepository): Response
  22.     {
  23.         $blocHeure = new BlocHeure();
  24.         $form $this->createForm(BlocHeureType::class, $blocHeure);
  25.         $form->handleRequest($request);
  26.         if ($form->isSubmitted() && $form->isValid()) {
  27.             $blocHeureRepository->add($blocHeuretrue);
  28.             return $this->redirectToRoute('app_bloc_heure_index', [], Response::HTTP_SEE_OTHER);
  29.         }
  30.         return $this->renderForm('bloc_heure/new.html.twig', [
  31.             'bloc_heure' => $blocHeure,
  32.             'form' => $form,
  33.         ]);
  34.     }
  35.     #[Route('/{id}'name'app_bloc_heure_show'methods: ['GET'])]
  36.     public function show(BlocHeure $blocHeure): Response
  37.     {
  38.         return $this->render('bloc_heure/show.html.twig', [
  39.             'bloc_heure' => $blocHeure,
  40.         ]);
  41.     }
  42.     #[Route('/{id}/edit'name'app_bloc_heure_edit'methods: ['GET''POST'])]
  43.     public function edit(Request $requestBlocHeure $blocHeureBlocHeureRepository $blocHeureRepository): Response
  44.     {
  45.         $form $this->createForm(BlocHeureType::class, $blocHeure);
  46.         $form->handleRequest($request);
  47.         if ($form->isSubmitted() && $form->isValid()) {
  48.             $blocHeureRepository->add($blocHeuretrue);
  49.             return $this->redirectToRoute('app_bloc_heure_index', [], Response::HTTP_SEE_OTHER);
  50.         }
  51.         return $this->renderForm('bloc_heure/edit.html.twig', [
  52.             'bloc_heure' => $blocHeure,
  53.             'form' => $form,
  54.         ]);
  55.     }
  56.     #[Route('/{id}'name'app_bloc_heure_delete'methods: ['POST'])]
  57.     public function delete(Request $requestBlocHeure $blocHeureBlocHeureRepository $blocHeureRepository): Response
  58.     {
  59.         if ($this->isCsrfTokenValid('delete'.$blocHeure->getId(), $request->request->get('_token'))) {
  60.             $blocHeureRepository->remove($blocHeuretrue);
  61.         }
  62.         return $this->redirectToRoute('app_bloc_heure_index', [], Response::HTTP_SEE_OTHER);
  63.     }
  64. }