WIP: feature_paste #1

Draft
Miroslavsckaya wants to merge 24 commits from feature_paste into master
Showing only changes of commit a442fe31f9 - Show all commits

View file

@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
class PasteController extends AbstractController class PasteController extends AbstractController
{ {
Review

I'd suggest explicitly defining which request methods we're processing here.

P.S. We'll move this to YAML in the end.

I'd suggest explicitly defining which request methods we're processing here. P.S. We'll move this to YAML in the end.
#[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
Review

show_paste at least.

`show_paste` at least.
{ {
$paste = $pasteRepository->findOneBy(['id' => $id, 'secret' => $secret]); $paste = $pasteRepository->findOneBy(['id' => $id, 'secret' => $secret]);