render('details_commande/index.html.twig', [ 'details_commandes' => $detailsCommandeRepository->findAll(), ]); } #[Route('/new', name: 'app_details_commande_new', methods: ['GET', 'POST'])] public function new(Request $request, EntityManagerInterface $entityManager): Response { $detailsCommande = new DetailsCommande(); $form = $this->createForm(DetailsCommandeType::class, $detailsCommande); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $entityManager->persist($detailsCommande); $entityManager->flush(); return $this->redirectToRoute('app_details_commande_index', [], Response::HTTP_SEE_OTHER); } return $this->render('details_commande/new.html.twig', [ 'details_commande' => $detailsCommande, 'form' => $form, ]); } #[Route('/{id}/edit', name: 'app_details_commande_edit', methods: ['GET', 'POST'])] public function edit(Request $request, DetailsCommande $detailsCommande, EntityManagerInterface $entityManager): Response { $form = $this->createForm(DetailsCommandeType::class, $detailsCommande); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $entityManager->flush(); return $this->redirectToRoute('app_details_commande_index', [], Response::HTTP_SEE_OTHER); } return $this->render('details_commande/edit.html.twig', [ 'details_commande' => $detailsCommande, 'form' => $form, ]); } #[Route('/{id}', name: 'app_details_commande_delete', methods: ['POST'])] public function delete(Request $request, DetailsCommande $detailsCommande, EntityManagerInterface $entityManager): Response { if ($this->isCsrfTokenValid('delete'.$detailsCommande->getId(), $request->getPayload()->getString('_token'))) { $entityManager->remove($detailsCommande); $entityManager->flush(); } return $this->redirectToRoute('app_details_commande_index', [], Response::HTTP_SEE_OTHER); } }