Skip to content

Commit

Permalink
minor symfony#1064 Use short syntax for routes HTTP methods (voronkov…
Browse files Browse the repository at this point in the history
…ich)

This PR was merged into the master branch.

Discussion
----------

Use short syntax for routes HTTP methods

BTW, short syntax is used in `bin/console debug:router` command's output.

Commits
-------

fccab56 Use short syntax for routes HTTP methods
  • Loading branch information
javiereguiluz committed Jan 8, 2020
2 parents 7cbada1 + fccab56 commit 177b652
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/Controller/Admin/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class BlogController extends AbstractController
* could move this annotation to any other controller while maintaining
* the route name and therefore, without breaking any existing link.
*
* @Route("/", methods={"GET"}, name="admin_index")
* @Route("/", methods={"GET"}, name="admin_post_index")
* @Route("/", methods="GET", name="admin_index")
* @Route("/", methods="GET", name="admin_post_index")
*/
public function index(PostRepository $posts): Response
{
Expand All @@ -64,7 +64,7 @@ public function index(PostRepository $posts): Response
/**
* Creates a new Post entity.
*
* @Route("/new", methods={"GET", "POST"}, name="admin_post_new")
* @Route("/new", methods="GET|POST", name="admin_post_new")
*
* NOTE: the Method annotation is optional, but it's a recommended practice
* to constraint the HTTP methods each controller responds to (by default
Expand Down Expand Up @@ -114,7 +114,7 @@ public function new(Request $request, SluggerInterface $slugger): Response
/**
* Finds and displays a Post entity.
*
* @Route("/{id<\d+>}", methods={"GET"}, name="admin_post_show")
* @Route("/{id<\d+>}", methods="GET", name="admin_post_show")
*/
public function show(Post $post): Response
{
Expand All @@ -130,7 +130,7 @@ public function show(Post $post): Response
/**
* Displays a form to edit an existing Post entity.
*
* @Route("/{id<\d+>}/edit",methods={"GET", "POST"}, name="admin_post_edit")
* @Route("/{id<\d+>}/edit", methods="GET|POST", name="admin_post_edit")
* @IsGranted("edit", subject="post", message="Posts can only be edited by their authors.")
*/
public function edit(Request $request, Post $post, SluggerInterface $slugger): Response
Expand All @@ -156,7 +156,7 @@ public function edit(Request $request, Post $post, SluggerInterface $slugger): R
/**
* Deletes a Post entity.
*
* @Route("/{id}/delete", methods={"POST"}, name="admin_post_delete")
* @Route("/{id}/delete", methods="POST", name="admin_post_delete")
* @IsGranted("delete", subject="post")
*/
public function delete(Request $request, Post $post): Response
Expand Down
12 changes: 6 additions & 6 deletions src/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
class BlogController extends AbstractController
{
/**
* @Route("/", defaults={"page": "1", "_format"="html"}, methods={"GET"}, name="blog_index")
* @Route("/rss.xml", defaults={"page": "1", "_format"="xml"}, methods={"GET"}, name="blog_rss")
* @Route("/page/{page<[1-9]\d*>}", defaults={"_format"="html"}, methods={"GET"}, name="blog_index_paginated")
* @Route("/", defaults={"page": "1", "_format"="html"}, methods="GET", name="blog_index")
* @Route("/rss.xml", defaults={"page": "1", "_format"="xml"}, methods="GET", name="blog_rss")
* @Route("/page/{page<[1-9]\d*>}", defaults={"_format"="html"}, methods="GET", name="blog_index_paginated")
* @Cache(smaxage="10")
*
* NOTE: For standard formats, Symfony will also automatically choose the best
Expand All @@ -63,7 +63,7 @@ public function index(Request $request, int $page, string $_format, PostReposito
}

/**
* @Route("/posts/{slug}", methods={"GET"}, name="blog_post")
* @Route("/posts/{slug}", methods="GET", name="blog_post")
*
* NOTE: The $post controller argument is automatically injected by Symfony
* after performing a database query looking for a Post with the 'slug'
Expand All @@ -83,7 +83,7 @@ public function postShow(Post $post): Response
}

/**
* @Route("/comment/{postSlug}/new", methods={"POST"}, name="comment_new")
* @Route("/comment/{postSlug}/new", methods="POST", name="comment_new")
* @IsGranted("IS_AUTHENTICATED_FULLY")
* @ParamConverter("post", options={"mapping": {"postSlug": "slug"}})
*
Expand Down Expand Up @@ -140,7 +140,7 @@ public function commentForm(Post $post): Response
}

/**
* @Route("/search", methods={"GET"}, name="blog_search")
* @Route("/search", methods="GET", name="blog_search")
*/
public function search(Request $request, PostRepository $posts): Response
{
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class UserController extends AbstractController
{
/**
* @Route("/edit", methods={"GET", "POST"}, name="user_edit")
* @Route("/edit", methods="GET|POST", name="user_edit")
*/
public function edit(Request $request): Response
{
Expand All @@ -55,7 +55,7 @@ public function edit(Request $request): Response
}

/**
* @Route("/change-password", methods={"GET", "POST"}, name="user_change_password")
* @Route("/change-password", methods="GET|POST", name="user_change_password")
*/
public function changePassword(Request $request, UserPasswordEncoderInterface $encoder): Response
{
Expand Down

0 comments on commit 177b652

Please sign in to comment.