Skip to content

Commit 5aa9b37

Browse files
committed
bug #789 remove the deprecated sensio/framework-extra-bundle @method annotations (christickner)
This PR was merged into the master branch. Discussion ---------- remove the deprecated sensio/framework-extra-bundle @method annotations fixes #785 Commits ------- 6f841e2 remove the deprecated sensio/framework-extra-bundle @method annotations
2 parents d94ed0a + 6f841e2 commit 5aa9b37

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

src/Controller/Admin/BlogController.php

+6-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use App\Form\PostType;
1616
use App\Repository\PostRepository;
1717
use App\Utils\Slugger;
18-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
1918
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
2019
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2120
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@@ -51,9 +50,8 @@ class BlogController extends AbstractController
5150
* could move this annotation to any other controller while maintaining
5251
* the route name and therefore, without breaking any existing link.
5352
*
54-
* @Route("/", name="admin_index")
55-
* @Route("/", name="admin_post_index")
56-
* @Method("GET")
53+
* @Route("/", methods={"GET"}, name="admin_index")
54+
* @Route("/", methods={"GET"}, name="admin_post_index")
5755
*/
5856
public function index(PostRepository $posts): Response
5957
{
@@ -65,8 +63,7 @@ public function index(PostRepository $posts): Response
6563
/**
6664
* Creates a new Post entity.
6765
*
68-
* @Route("/new", name="admin_post_new")
69-
* @Method({"GET", "POST"})
66+
* @Route("/new", methods={"GET", "POST"}, name="admin_post_new")
7067
*
7168
* NOTE: the Method annotation is optional, but it's a recommended practice
7269
* to constraint the HTTP methods each controller responds to (by default
@@ -116,8 +113,7 @@ public function new(Request $request): Response
116113
/**
117114
* Finds and displays a Post entity.
118115
*
119-
* @Route("/{id}", requirements={"id": "\d+"}, name="admin_post_show")
120-
* @Method("GET")
116+
* @Route("/{id}", requirements={"id": "\d+"}, methods={"GET"}, name="admin_post_show")
121117
*/
122118
public function show(Post $post): Response
123119
{
@@ -133,8 +129,7 @@ public function show(Post $post): Response
133129
/**
134130
* Displays a form to edit an existing Post entity.
135131
*
136-
* @Route("/{id}/edit", requirements={"id": "\d+"}, name="admin_post_edit")
137-
* @Method({"GET", "POST"})
132+
* @Route("/{id}/edit", requirements={"id": "\d+"}, methods={"GET", "POST"}, name="admin_post_edit")
138133
*/
139134
public function edit(Request $request, Post $post): Response
140135
{
@@ -161,8 +156,7 @@ public function edit(Request $request, Post $post): Response
161156
/**
162157
* Deletes a Post entity.
163158
*
164-
* @Route("/{id}/delete", name="admin_post_delete")
165-
* @Method("POST")
159+
* @Route("/{id}/delete", methods={"POST"}, name="admin_post_delete")
166160
* @Security("is_granted('delete', post)")
167161
*
168162
* The Security annotation value is an expression (if it evaluates to false,

src/Controller/BlogController.php

+6-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use App\Form\CommentType;
1818
use App\Repository\PostRepository;
1919
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
20-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
2120
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
2221
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
2322
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -38,10 +37,9 @@
3837
class BlogController extends AbstractController
3938
{
4039
/**
41-
* @Route("/", defaults={"page": "1", "_format"="html"}, name="blog_index")
42-
* @Route("/rss.xml", defaults={"page": "1", "_format"="xml"}, name="blog_rss")
43-
* @Route("/page/{page}", defaults={"_format"="html"}, requirements={"page": "[1-9]\d*"}, name="blog_index_paginated")
44-
* @Method("GET")
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}", defaults={"_format"="html"}, requirements={"page": "[1-9]\d*"}, methods={"GET"}, name="blog_index_paginated")
4543
* @Cache(smaxage="10")
4644
*
4745
* NOTE: For standard formats, Symfony will also automatically choose the best
@@ -59,8 +57,7 @@ public function index(int $page, string $_format, PostRepository $posts): Respon
5957
}
6058

6159
/**
62-
* @Route("/posts/{slug}", name="blog_post")
63-
* @Method("GET")
60+
* @Route("/posts/{slug}", methods={"GET"}, name="blog_post")
6461
*
6562
* NOTE: The $post controller argument is automatically injected by Symfony
6663
* after performing a database query looking for a Post with the 'slug'
@@ -80,8 +77,7 @@ public function postShow(Post $post): Response
8077
}
8178

8279
/**
83-
* @Route("/comment/{postSlug}/new", name="comment_new")
84-
* @Method("POST")
80+
* @Route("/comment/{postSlug}/new", methods={"POST"}, name="comment_new")
8581
* @Security("is_granted('IS_AUTHENTICATED_FULLY')")
8682
* @ParamConverter("post", options={"mapping": {"postSlug": "slug"}})
8783
*
@@ -145,8 +141,7 @@ public function commentForm(Post $post): Response
145141
}
146142

147143
/**
148-
* @Route("/search", name="blog_search")
149-
* @Method("GET")
144+
* @Route("/search", methods={"GET"}, name="blog_search")
150145
*/
151146
public function search(Request $request, PostRepository $posts): Response
152147
{

0 commit comments

Comments
 (0)