Skip to content

Commit

Permalink
bug #789 remove the deprecated sensio/framework-extra-bundle @method
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
javiereguiluz committed Apr 25, 2018
2 parents d94ed0a + 6f841e2 commit 5aa9b37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
18 changes: 6 additions & 12 deletions src/Controller/Admin/BlogController.php
Expand Up @@ -15,7 +15,6 @@
use App\Form\PostType;
use App\Repository\PostRepository;
use App\Utils\Slugger;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
Expand Down Expand Up @@ -51,9 +50,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("/", name="admin_index")
* @Route("/", name="admin_post_index")
* @Method("GET")
* @Route("/", methods={"GET"}, name="admin_index")
* @Route("/", methods={"GET"}, name="admin_post_index")
*/
public function index(PostRepository $posts): Response
{
Expand All @@ -65,8 +63,7 @@ public function index(PostRepository $posts): Response
/**
* Creates a new Post entity.
*
* @Route("/new", name="admin_post_new")
* @Method({"GET", "POST"})
* @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 @@ -116,8 +113,7 @@ public function new(Request $request): Response
/**
* Finds and displays a Post entity.
*
* @Route("/{id}", requirements={"id": "\d+"}, name="admin_post_show")
* @Method("GET")
* @Route("/{id}", requirements={"id": "\d+"}, methods={"GET"}, name="admin_post_show")
*/
public function show(Post $post): Response
{
Expand All @@ -133,8 +129,7 @@ public function show(Post $post): Response
/**
* Displays a form to edit an existing Post entity.
*
* @Route("/{id}/edit", requirements={"id": "\d+"}, name="admin_post_edit")
* @Method({"GET", "POST"})
* @Route("/{id}/edit", requirements={"id": "\d+"}, methods={"GET", "POST"}, name="admin_post_edit")
*/
public function edit(Request $request, Post $post): Response
{
Expand All @@ -161,8 +156,7 @@ public function edit(Request $request, Post $post): Response
/**
* Deletes a Post entity.
*
* @Route("/{id}/delete", name="admin_post_delete")
* @Method("POST")
* @Route("/{id}/delete", methods={"POST"}, name="admin_post_delete")
* @Security("is_granted('delete', post)")
*
* The Security annotation value is an expression (if it evaluates to false,
Expand Down
17 changes: 6 additions & 11 deletions src/Controller/BlogController.php
Expand Up @@ -17,7 +17,6 @@
use App\Form\CommentType;
use App\Repository\PostRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
Expand All @@ -38,10 +37,9 @@
class BlogController extends AbstractController
{
/**
* @Route("/", defaults={"page": "1", "_format"="html"}, name="blog_index")
* @Route("/rss.xml", defaults={"page": "1", "_format"="xml"}, name="blog_rss")
* @Route("/page/{page}", defaults={"_format"="html"}, requirements={"page": "[1-9]\d*"}, name="blog_index_paginated")
* @Method("GET")
* @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}", defaults={"_format"="html"}, requirements={"page": "[1-9]\d*"}, methods={"GET"}, name="blog_index_paginated")
* @Cache(smaxage="10")
*
* NOTE: For standard formats, Symfony will also automatically choose the best
Expand All @@ -59,8 +57,7 @@ public function index(int $page, string $_format, PostRepository $posts): Respon
}

/**
* @Route("/posts/{slug}", name="blog_post")
* @Method("GET")
* @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 @@ -80,8 +77,7 @@ public function postShow(Post $post): Response
}

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

/**
* @Route("/search", name="blog_search")
* @Method("GET")
* @Route("/search", methods={"GET"}, name="blog_search")
*/
public function search(Request $request, PostRepository $posts): Response
{
Expand Down

0 comments on commit 5aa9b37

Please sign in to comment.