From a442fe31f9711eb99950997d2d464ff8f85f8a86 Mon Sep 17 00:00:00 2001 From: mitsuha_s Date: Sun, 23 Jul 2023 15:23:30 +0300 Subject: [PATCH] redirect to paste page added --- src/Controller/PasteController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Controller/PasteController.php b/src/Controller/PasteController.php index 6f411f6..057f0d2 100644 --- a/src/Controller/PasteController.php +++ b/src/Controller/PasteController.php @@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Request; class PasteController extends AbstractController { - #[Route('/')] + #[Route('/', name: 'homepage')] public function new(Request $request, PasteRepository $pasteRepository): Response { $pasteData = new PasteFormData(); @@ -28,7 +28,7 @@ class PasteController extends AbstractController $paste = Paste::fromFormDataAndIp($pasteData, $request->getClientIp()); $pasteRepository->save($paste, true); - return $this->redirectToRoute($request->attributes->get('_route')); + return $this->redirectToRoute('showpaste', ['id' => $paste->id, 'secret' => $paste->secret]); } return $this->render('paste.html.twig', [ @@ -36,7 +36,7 @@ class PasteController extends AbstractController ]); } - #[Route('/{id}/{secret}')] + #[Route('/{id}/{secret}', name: 'showpaste')] public function showPaste(PasteRepository $pasteRepository, string $id, ?string $secret = NULL): Response { $paste = $pasteRepository->findOneBy(['id' => $id, 'secret' => $secret]);