Skip to content

Commit 177b652

Browse files
committed
minor #1064 Use short syntax for routes HTTP methods (voronkovich)
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
2 parents 7cbada1 + fccab56 commit 177b652

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/Controller/Admin/BlogController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class BlogController extends AbstractController
5151
* could move this annotation to any other controller while maintaining
5252
* the route name and therefore, without breaking any existing link.
5353
*
54-
* @Route("/", methods={"GET"}, name="admin_index")
55-
* @Route("/", methods={"GET"}, name="admin_post_index")
54+
* @Route("/", methods="GET", name="admin_index")
55+
* @Route("/", methods="GET", name="admin_post_index")
5656
*/
5757
public function index(PostRepository $posts): Response
5858
{
@@ -64,7 +64,7 @@ public function index(PostRepository $posts): Response
6464
/**
6565
* Creates a new Post entity.
6666
*
67-
* @Route("/new", methods={"GET", "POST"}, name="admin_post_new")
67+
* @Route("/new", methods="GET|POST", name="admin_post_new")
6868
*
6969
* NOTE: the Method annotation is optional, but it's a recommended practice
7070
* to constraint the HTTP methods each controller responds to (by default
@@ -114,7 +114,7 @@ public function new(Request $request, SluggerInterface $slugger): Response
114114
/**
115115
* Finds and displays a Post entity.
116116
*
117-
* @Route("/{id<\d+>}", methods={"GET"}, name="admin_post_show")
117+
* @Route("/{id<\d+>}", methods="GET", name="admin_post_show")
118118
*/
119119
public function show(Post $post): Response
120120
{
@@ -130,7 +130,7 @@ public function show(Post $post): Response
130130
/**
131131
* Displays a form to edit an existing Post entity.
132132
*
133-
* @Route("/{id<\d+>}/edit",methods={"GET", "POST"}, name="admin_post_edit")
133+
* @Route("/{id<\d+>}/edit", methods="GET|POST", name="admin_post_edit")
134134
* @IsGranted("edit", subject="post", message="Posts can only be edited by their authors.")
135135
*/
136136
public function edit(Request $request, Post $post, SluggerInterface $slugger): Response
@@ -156,7 +156,7 @@ public function edit(Request $request, Post $post, SluggerInterface $slugger): R
156156
/**
157157
* Deletes a Post entity.
158158
*
159-
* @Route("/{id}/delete", methods={"POST"}, name="admin_post_delete")
159+
* @Route("/{id}/delete", methods="POST", name="admin_post_delete")
160160
* @IsGranted("delete", subject="post")
161161
*/
162162
public function delete(Request $request, Post $post): Response

src/Controller/BlogController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
class BlogController extends AbstractController
3838
{
3939
/**
40-
* @Route("/", defaults={"page": "1", "_format"="html"}, methods={"GET"}, name="blog_index")
41-
* @Route("/rss.xml", defaults={"page": "1", "_format"="xml"}, methods={"GET"}, name="blog_rss")
42-
* @Route("/page/{page<[1-9]\d*>}", defaults={"_format"="html"}, methods={"GET"}, name="blog_index_paginated")
40+
* @Route("/", defaults={"page": "1", "_format"="html"}, methods="GET", name="blog_index")
41+
* @Route("/rss.xml", defaults={"page": "1", "_format"="xml"}, methods="GET", name="blog_rss")
42+
* @Route("/page/{page<[1-9]\d*>}", defaults={"_format"="html"}, methods="GET", name="blog_index_paginated")
4343
* @Cache(smaxage="10")
4444
*
4545
* NOTE: For standard formats, Symfony will also automatically choose the best
@@ -63,7 +63,7 @@ public function index(Request $request, int $page, string $_format, PostReposito
6363
}
6464

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

8585
/**
86-
* @Route("/comment/{postSlug}/new", methods={"POST"}, name="comment_new")
86+
* @Route("/comment/{postSlug}/new", methods="POST", name="comment_new")
8787
* @IsGranted("IS_AUTHENTICATED_FULLY")
8888
* @ParamConverter("post", options={"mapping": {"postSlug": "slug"}})
8989
*
@@ -140,7 +140,7 @@ public function commentForm(Post $post): Response
140140
}
141141

142142
/**
143-
* @Route("/search", methods={"GET"}, name="blog_search")
143+
* @Route("/search", methods="GET", name="blog_search")
144144
*/
145145
public function search(Request $request, PostRepository $posts): Response
146146
{

src/Controller/UserController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
class UserController extends AbstractController
3232
{
3333
/**
34-
* @Route("/edit", methods={"GET", "POST"}, name="user_edit")
34+
* @Route("/edit", methods="GET|POST", name="user_edit")
3535
*/
3636
public function edit(Request $request): Response
3737
{
@@ -55,7 +55,7 @@ public function edit(Request $request): Response
5555
}
5656

5757
/**
58-
* @Route("/change-password", methods={"GET", "POST"}, name="user_change_password")
58+
* @Route("/change-password", methods="GET|POST", name="user_change_password")
5959
*/
6060
public function changePassword(Request $request, UserPasswordEncoderInterface $encoder): Response
6161
{

0 commit comments

Comments
 (0)