Skip to content

Commit c1e8453

Browse files
committed
[Book][Routing] Change example to match multiple methods
1 parent c1dac43 commit c1e8453

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

book/routing.rst

+20-20
Original file line numberDiff line numberDiff line change
@@ -833,36 +833,36 @@ be accomplished with the following route configuration:
833833
class MainController extends Controller
834834
{
835835
/**
836-
* @Route("/contact")
836+
* @Route("/news")
837837
* @Method("GET")
838838
*/
839-
public function contactAction()
839+
public function newsAction()
840840
{
841-
// ... display contact form
841+
// ... display your news
842842
}
843843
844844
/**
845845
* @Route("/contact")
846-
* @Method("POST")
846+
* @Method({"GET", "POST"})
847847
*/
848-
public function processContactAction()
848+
public function contactFormAction()
849849
{
850-
// ... process contact form
850+
// ... display and process a contact form
851851
}
852852
}
853853
854854
.. code-block:: yaml
855855
856856
# app/config/routing.yml
857-
contact:
858-
path: /contact
859-
defaults: { _controller: AppBundle:Main:contact }
857+
news:
858+
path: /news
859+
defaults: { _controller: AppBundle:Main:news }
860860
methods: [GET]
861861
862-
contact_process:
862+
contact_form:
863863
path: /contact
864-
defaults: { _controller: AppBundle:Main:processContact }
865-
methods: [POST]
864+
defaults: { _controller: AppBundle:Main:contactForm }
865+
methods: [GET, POST]
866866
867867
.. code-block:: xml
868868
@@ -873,12 +873,12 @@ be accomplished with the following route configuration:
873873
xsi:schemaLocation="http://symfony.com/schema/routing
874874
http://symfony.com/schema/routing/routing-1.0.xsd">
875875
876-
<route id="contact" path="/contact" methods="GET">
877-
<default key="_controller">AppBundle:Main:contact</default>
876+
<route id="news" path="/news" methods="GET">
877+
<default key="_controller">AppBundle:Main:news</default>
878878
</route>
879879
880-
<route id="contact_process" path="/contact" methods="POST">
881-
<default key="_controller">AppBundle:Main:processContact</default>
880+
<route id="contact_form" path="/contact" methods="GET|POST">
881+
<default key="_controller">AppBundle:Main:contactForm</default>
882882
</route>
883883
</routes>
884884
@@ -889,13 +889,13 @@ be accomplished with the following route configuration:
889889
use Symfony\Component\Routing\Route;
890890
891891
$collection = new RouteCollection();
892-
$collection->add('contact', new Route('/contact', array(
892+
$collection->add('news', new Route('/news', array(
893893
'_controller' => 'AppBundle:Main:contact',
894894
), array(), array(), '', array(), array('GET')));
895895
896-
$collection->add('contact_process', new Route('/contact', array(
897-
'_controller' => 'AppBundle:Main:processContact',
898-
), array(), array(), '', array(), array('POST')));
896+
$collection->add('contact_form', new Route('/contact', array(
897+
'_controller' => 'AppBundle:Main:contactForm',
898+
), array(), array(), '', array(), array('GET', 'POST')));
899899
900900
return $collection;
901901

0 commit comments

Comments
 (0)