getDoctrine() ->getRepository(::class) ->findAll(); return $this->render('/index.html.twig', [ '' => $, ]); } /** * @Route("/new", name="_new", methods={"GET","POST"}) */ public function new(Request $request): Response { $ = new (); $form = $this->createForm(::class, $); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $entityManager = $this->getDoctrine()->getManager(); $entityManager->persist($); $entityManager->flush(); return $this->redirectToRoute('_index'); } return $this->render('/new.html.twig', [ '' => $, 'form' => $form->createView(), ]); } /** * @Route("/{}", name="_show", methods={"GET"}) */ public function show( $): Response { return $this->render('/show.html.twig', [ '' => $, ]); } /** * @Route("/{}/edit", name="_edit", methods={"GET","POST"}) */ public function edit(Request $request, $): Response { $form = $this->createForm(::class, $); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirectToRoute('_index'); } return $this->render('/edit.html.twig', [ '' => $, 'form' => $form->createView(), ]); } /** * @Route("/{}", name="_delete", methods={"POST"}) */ public function delete(Request $request, $): Response { if ($this->isCsrfTokenValid('delete'.$->get(), $request->request->get('_token'))) { $entityManager = $this->getDoctrine()->getManager(); $entityManager->remove($); $entityManager->flush(); } return $this->redirectToRoute('_index'); } }