render('group_of_products/index.html.twig', [ 'group_of_products' => $groupOfProductsRepository->findAll(), ]); } #[Route('/new', name: 'app_group_of_products_new', methods: ['GET', 'POST'])] public function new(Request $request, EntityManagerInterface $entityManager): Response { $groupOfProduct = new GroupOfProducts(); $form = $this->createForm(GroupOfProductsType::class, $groupOfProduct); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $entityManager->persist($groupOfProduct); $entityManager->flush(); return $this->redirectToRoute('app_group_of_products_index', [], Response::HTTP_SEE_OTHER); } return $this->render('group_of_products/new.html.twig', [ 'group_of_product' => $groupOfProduct, 'form' => $form, ]); } #[Route('/{id}', name: 'app_group_of_products_show', methods: ['GET'])] public function show(GroupOfProducts $groupOfProduct): Response { return $this->render('group_of_products/show.html.twig', [ 'group_of_product' => $groupOfProduct, ]); } #[Route('/{id}/edit', name: 'app_group_of_products_edit', methods: ['GET', 'POST'])] public function edit(Request $request, GroupOfProducts $groupOfProduct, EntityManagerInterface $entityManager): Response { $form = $this->createForm(GroupOfProductsType::class, $groupOfProduct); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $entityManager->flush(); return $this->redirectToRoute('app_group_of_products_index', [], Response::HTTP_SEE_OTHER); } return $this->render('group_of_products/edit.html.twig', [ 'group_of_product' => $groupOfProduct, 'form' => $form, ]); } #[Route('/{id}', name: 'app_group_of_products_delete', methods: ['POST'])] public function delete(Request $request, GroupOfProducts $groupOfProduct, EntityManagerInterface $entityManager): Response { if ($this->isCsrfTokenValid('delete'.$groupOfProduct->getId(), $request->getPayload()->getString('_token'))) { $entityManager->remove($groupOfProduct); $entityManager->flush(); } return $this->redirectToRoute('app_group_of_products_index', [], Response::HTTP_SEE_OTHER); } }