Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
[book] fixes typo about redirect status codes in the controller chapter.#6220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -438,7 +438,7 @@ If you want to redirect the user to another page, use the ``redirectToRoute()`` | ||
return $this->redirectToRoute('homepage'); | ||
// redirectToRoute is equivalent to using redirect() and generateUrl() together: | ||
// return $this->redirect($this->generateUrl('homepage')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I'm not sure this is a typo. The default value of the second argument of protectedfunctionredirect($url,$status =302) {returnnewRedirectResponse($url,$status); } There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. By default, both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. class Controller{/** * Returns a RedirectResponse to the given URL. * * @param string $url The URL to redirect to * @param int $status The status code to use for the Response * * @return RedirectResponse */protectedfunctionredirect($url,$status =302) {returnnewRedirectResponse($url,$status); }/** * Returns a RedirectResponse to the given route with the given parameters. * * @param string $route The name of the route * @param array $parameters An array of parameters * @param int $status The status code to use for the Response * * @return RedirectResponse */protectedfunctionredirectToRoute($route,array$parameters =array(),$status =302) {return$this->redirect($this->generateUrl($route,$parameters),$status); }} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. you are right@hhamon, but to have an example of a status code is not bad imo, what about changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Would you like to open a pull request for that change? By the way, I do not think we need a complete example for that, but we could add a note talking about the fact that redirects by default are responses with a 302 status code but that you can change them through the last parameter of both methods. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Sure! Will do ;) | ||
} | ||
.. versionadded:: 2.6 | ||