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()) { $em = $this->getDoctrine()->getManager(); $em->persist($); $em->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', ['' => $->get()]); } return $this->render('/edit.html.twig', [ '' => $, 'form' => $form->createView(), ]); } /** * @Route("/{}", name="_delete", methods="DELETE") */ public function delete(Request $request, $): Response { if ($this->isCsrfTokenValid('delete'.$->get(), $request->request->get('_token'))) { $em = $this->getDoctrine()->getManager(); $em->remove($); $em->flush(); } return $this->redirectToRoute('_index'); } }