find($id); if (!$page) { throw $this->createNotFoundException('La page ' . $id . ' n\'existe pas.'); } return $this->render('page/index.html.twig', [ 'page' => $page ]); } #[Route('/p/edit/{id}', name: 'app_page_edit', methods: ['GET', 'POST'])] public function editPage(Request $request, Page $page, EntityManagerInterface $em): Response { $form = $this->createForm(PageType::class, $page); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em->flush(); $this->addFlash('success', 'Contenu modifié'); return $this->redirectToRoute('app_page_show', ['name' => $page->getName()]); } return $this->render('page/edit.html.twig', [ 'title' => $page->getName(), 'form' => $form ]); } }