Skip to content

Commit c1d1df6

Browse files
committed
minor #16206 Using const Response::HTTP_MOVED_PERMANENTLY for redirect (ThomasLandauer)
This PR was merged into the 4.4 branch. Discussion ---------- Using const `Response::HTTP_MOVED_PERMANENTLY` for redirect Commits ------- 73b847d Using const `Response::HTTP_MOVED_PERMANENTLY` for redirect
2 parents 62c0653 + 73b847d commit c1d1df6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

controller.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +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
135136

136137
// ...
137138
public function index(): RedirectResponse
@@ -142,8 +143,8 @@ and ``redirect()`` methods::
142143
// redirectToRoute is a shortcut for:
143144
// return new RedirectResponse($this->generateUrl('homepage'));
144145

145-
// does a permanent - 301 redirect
146-
return $this->redirectToRoute('homepage', [], 301);
146+
// does a permanent HTTP 301 redirect
147+
return $this->redirectToRoute('homepage', [], Response::HTTP_MOVED_PERMANENTLY);
147148

148149
// redirect to a route with parameters
149150
return $this->redirectToRoute('app_lucky_number', ['max' => 10]);

0 commit comments

Comments
 (0)