Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc1e8453

Browse files
committed
[Book][Routing] Change example to match multiple methods
1 parentc1dac43 commitc1e8453

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

‎book/routing.rst‎

Lines changed: 20 additions & 20 deletions
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 functioncontactAction()
839+
public functionnewsAction()
840840
{
841-
// ... displaycontact form
841+
// ... displayyour news
842842
}
843843
844844
/**
845845
* @Route("/contact")
846-
* @Method("POST")
846+
* @Method({"GET", "POST"})
847847
*/
848-
public functionprocessContactAction()
848+
public functioncontactFormAction()
849849
{
850-
// ... process contact form
850+
// ...display andprocess 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-
<routeid="contact"path="/contact"methods="GET">
877-
<defaultkey="_controller">AppBundle:Main:contact</default>
876+
<routeid="news"path="/news"methods="GET">
877+
<defaultkey="_controller">AppBundle:Main:news</default>
878878
</route>
879879
880-
<routeid="contact_process"path="/contact"methods="POST">
881-
<defaultkey="_controller">AppBundle:Main:processContact</default>
880+
<routeid="contact_form"path="/contact"methods="GET|POST">
881+
<defaultkey="_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)

[8]ページ先頭

©2009-2025 Movatter.jp