1
0
Fork 0

not found on wrong post in main page

This commit is contained in:
Ethanell 2021-01-17 16:24:46 +01:00
parent cfe7d9339c
commit 86f4accd78

View file

@ -45,6 +45,9 @@ class PostController extends AbstractController
public function post(Request $request, string $slug): Response public function post(Request $request, string $slug): Response
{ {
$post = $this->getDoctrine()->getRepository(Post::class)->findOneBy(array('slug' => $slug)); $post = $this->getDoctrine()->getRepository(Post::class)->findOneBy(array('slug' => $slug));
if (!$post) {
throw $this->createNotFoundException("Post not found");
}
$form = $this->commentFormGenerator($post); $form = $this->commentFormGenerator($post);
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {