diff --git a/src/AppBundle/Controller/Admin/BlogController.php b/src/AppBundle/Controller/Admin/BlogController.php index 80240dcac..e26a29ade 100644 --- a/src/AppBundle/Controller/Admin/BlogController.php +++ b/src/AppBundle/Controller/Admin/BlogController.php @@ -111,7 +111,7 @@ public function newAction(Request $request) /** * Finds and displays a Post entity. * - * @Route("/{id}", requirements={"id" = "\d+"}, name="admin_post_show") + * @Route("/{id}", requirements={"id": "\d+"}, name="admin_post_show") * @Method("GET") */ public function showAction(Post $post) @@ -134,7 +134,7 @@ public function showAction(Post $post) /** * Displays a form to edit an existing Post entity. * - * @Route("/{id}/edit", requirements={"id" = "\d+"}, name="admin_post_edit") + * @Route("/{id}/edit", requirements={"id": "\d+"}, name="admin_post_edit") * @Method({"GET", "POST"}) */ public function editAction(Post $post, Request $request) diff --git a/src/AppBundle/Controller/BlogController.php b/src/AppBundle/Controller/BlogController.php index 140518f40..520691025 100644 --- a/src/AppBundle/Controller/BlogController.php +++ b/src/AppBundle/Controller/BlogController.php @@ -33,8 +33,9 @@ class BlogController extends Controller { /** - * @Route("/", name="blog_index", defaults={"page" = 1}) - * @Route("/page/{page}", name="blog_index_paginated", requirements={"page" : "\d+"}) + * @Route("/", defaults={"page": 1}, name="blog_index") + * @Route("/page/{page}", requirements={"page": "[1-9]\d*"}, name="blog_index_paginated") + * @Method("GET") * @Cache(smaxage="10") */ public function indexAction($page) @@ -45,11 +46,16 @@ public function indexAction($page) $posts = $paginator->paginate($query, $page, Post::NUM_ITEMS); $posts->setUsedRoute('blog_index_paginated'); + if (0 === count($posts)) { + throw $this->createNotFoundException(); + } + return $this->render('blog/index.html.twig', array('posts' => $posts)); } /** * @Route("/posts/{slug}", name="blog_post") + * @Method("GET") * * NOTE: The $post controller argument is automatically injected by Symfony * after performing a database query looking for a Post with the 'slug' @@ -62,10 +68,9 @@ public function postShowAction(Post $post) } /** - * @Route("/comment/{postSlug}/new", name = "comment_new") - * @Security("is_granted('IS_AUTHENTICATED_FULLY')") - * + * @Route("/comment/{postSlug}/new", name="comment_new") * @Method("POST") + * @Security("is_granted('IS_AUTHENTICATED_FULLY')") * @ParamConverter("post", options={"mapping": {"postSlug": "slug"}}) * * NOTE: The ParamConverter mapping is required because the route parameter diff --git a/src/AppBundle/Controller/SecurityController.php b/src/AppBundle/Controller/SecurityController.php index 50b77216d..7e6203dbe 100644 --- a/src/AppBundle/Controller/SecurityController.php +++ b/src/AppBundle/Controller/SecurityController.php @@ -12,6 +12,7 @@ namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; /** @@ -25,6 +26,7 @@ class SecurityController extends Controller { /** * @Route("/login", name="security_login_form") + * @Method("GET") */ public function loginAction() {