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

Commitdbd274c

Browse files
committed
minor#16211 Adding redirect to current route (ThomasLandauer)
This PR was merged into the 4.4 branch.Discussion----------Adding redirect to current routeTaken fromsymfony/symfony#44485 (comment)Plus fixing syntax error I missed in#16206Commits-------f4122ee Adding redirect to current route
2 parents83bdd35 +f4122ee commitdbd274c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎controller.rst‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ If you want to redirect the user to another page, use the ``redirectToRoute()``
132132
and ``redirect()`` methods::
133133

134134
use Symfony\Component\HttpFoundation\RedirectResponse;
135-
use Symfony\Component\HttpFoundation\Response
135+
use Symfony\Component\HttpFoundation\Response;
136136

137137
// ...
138138
public function index(): RedirectResponse
@@ -153,6 +153,9 @@ and ``redirect()`` methods::
153153

154154
// redirects to a route and maintains the original query string parameters
155155
return $this->redirectToRoute('blog_show', $request->query->all());
156+
157+
// redirects to the current route (e.g. for Post/Redirect/Get pattern):
158+
return $this->redirectToRoute($request->attributes->get('_route'));
156159

157160
// redirects externally
158161
return $this->redirect('http://symfony.com/doc');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp