From 552b5f06e54f0c8292655e919189f70a2c10ff9e Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Sun, 11 Oct 2015 23:58:32 +0200 Subject: [PATCH] Update example for method requirements The example was not doing what the text said it did, as it did not have two routes with the same url but different methods. Updated all four examples (annotations, yaml, xml and php) --- book/routing.rst | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/book/routing.rst b/book/routing.rst index 4476031a7c9..08d26d64eb9 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("/news") + * @Route("/contact") * @Method("GET") */ - public function newsAction() + public function contactAction() { - // ... display your news + // ... display your contact form } /** * @Route("/contact") - * @Method({"GET", "POST"}) + * @Method({"POST"}) */ - public function contactFormAction() + public function contactProcessAction() { - // ... display and process a contact form + // ... process your contact form } } .. code-block:: yaml # app/config/routing.yml - news: - path: /news - defaults: { _controller: AppBundle:Main:news } + contact: + path: /contact + defaults: { _controller: AppBundle:Main:contact } methods: [GET] - contact_form: + contact_process: path: /contact - defaults: { _controller: AppBundle:Main:contactForm } - methods: [GET, POST] + defaults: { _controller: AppBundle:Main:contactProcess } + methods: [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:news + + AppBundle:Main:contact - - AppBundle:Main:contactForm + + AppBundle:Main:contactProcess @@ -889,13 +889,13 @@ be accomplished with the following route configuration: use Symfony\Component\Routing\Route; $collection = new RouteCollection(); - $collection->add('news', new Route('/news', array( + $collection->add('contact', new Route('/contact', array( '_controller' => 'AppBundle:Main:contact', ), array(), array(), '', array(), array('GET'))); - $collection->add('contact_form', new Route('/contact', array( - '_controller' => 'AppBundle:Main:contactForm', - ), array(), array(), '', array(), array('GET', 'POST'))); + $collection->add('contact_process', new Route('/contact', array( + '_controller' => 'AppBundle:Main:contactProcess', + ), array(), array(), '', array(), array('POST'))); return $collection;