From 9f4c0f9f02326509a116040aca87f2affb2045cc Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 23 Jun 2014 07:27:04 +0000 Subject: [PATCH] Throw 404 error if the article cannot be found --- .../FrontBundle/Controller/BlogController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/GergelyPolonkai/FrontBundle/Controller/BlogController.php b/src/GergelyPolonkai/FrontBundle/Controller/BlogController.php index 988d4d0..e843eb9 100644 --- a/src/GergelyPolonkai/FrontBundle/Controller/BlogController.php +++ b/src/GergelyPolonkai/FrontBundle/Controller/BlogController.php @@ -73,7 +73,11 @@ class BlogController extends Controller $query->setParameter(':slug', $slug); $query->setParameter(':date1', $date); $query->setParameter(':date2', $date2); - $post = $query->getOneOrNullResult(); + + if (($post = $query->getOneOrNullResult()) === null) { + throw $this->createNotFoundException('The post you specified does not exist.'); + } + $this->get('fpn_tag.tag_manager')->loadTagging($post); return array(