redirect to paste page added
This commit is contained in:
parent
ce545176c0
commit
a442fe31f9
|
@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class PasteController extends AbstractController
|
class PasteController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/')]
|
#[Route('/', name: 'homepage')]
|
||||||
public function new(Request $request, PasteRepository $pasteRepository): Response
|
public function new(Request $request, PasteRepository $pasteRepository): Response
|
||||||
{
|
{
|
||||||
$pasteData = new PasteFormData();
|
$pasteData = new PasteFormData();
|
||||||
|
@ -28,7 +28,7 @@ class PasteController extends AbstractController
|
||||||
$paste = Paste::fromFormDataAndIp($pasteData, $request->getClientIp());
|
$paste = Paste::fromFormDataAndIp($pasteData, $request->getClientIp());
|
||||||
$pasteRepository->save($paste, true);
|
$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', [
|
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
|
public function showPaste(PasteRepository $pasteRepository, string $id, ?string $secret = NULL): Response
|
||||||
{
|
{
|
||||||
$paste = $pasteRepository->findOneBy(['id' => $id, 'secret' => $secret]);
|
$paste = $pasteRepository->findOneBy(['id' => $id, 'secret' => $secret]);
|
||||||
|
|
Loading…
Reference in a new issue