From c1e8453636ba1ea65677e6c8b4493a58d7f729a2 Mon Sep 17 00:00:00 2001 From: Alexander Schwenn Date: Wed, 15 Jul 2015 22:43:55 +0200 Subject: [PATCH] [Book][Routing] Change example to match multiple methods --- book/routing.rst | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/book/routing.rst b/book/routing.rst index 14968290474..4476031a7c9 100644 --- a/book/routing.rst +++ b/book/routing.rst @@ -833,36 +833,36 @@ be accomplished with the following route configuration: class MainController extends Controller { /** - * @Route("/contact") + * @Route("/news") * @Method("GET") */ - public function contactAction() + public function newsAction() { - // ... display contact form + // ... display your news } /** * @Route("/contact") - * @Method("POST") + * @Method({"GET", "POST"}) */ - public function processContactAction() + public function contactFormAction() { - // ... process contact form + // ... display and process a contact form } } .. code-block:: yaml # app/config/routing.yml - contact: - path: /contact - defaults: { _controller: AppBundle:Main:contact } + news: + path: /news + defaults: { _controller: AppBundle:Main:news } methods: [GET] - contact_process: + contact_form: path: /contact - defaults: { _controller: AppBundle:Main:processContact } - methods: [POST] + defaults: { _controller: AppBundle:Main:contactForm } + methods: [GET, POST] .. code-block:: xml @@ -873,12 +873,12 @@ be accomplished with the following route configuration: xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - - AppBundle:Main:contact + + AppBundle:Main:news - - AppBundle:Main:processContact + + AppBundle:Main:contactForm @@ -889,13 +889,13 @@ be accomplished with the following route configuration: use Symfony\Component\Routing\Route; $collection = new RouteCollection(); - $collection->add('contact', new Route('/contact', array( + $collection->add('news', new Route('/news', array( '_controller' => 'AppBundle:Main:contact', ), array(), array(), '', array(), array('GET'))); - $collection->add('contact_process', new Route('/contact', array( - '_controller' => 'AppBundle:Main:processContact', - ), array(), array(), '', array(), array('POST'))); + $collection->add('contact_form', new Route('/contact', array( + '_controller' => 'AppBundle:Main:contactForm', + ), array(), array(), '', array(), array('GET', 'POST'))); return $collection;