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

Appearance settings

Commit af32590

Browse filesBrowse files
committed
[FrameworkBundle] Use only _route_params to generate redirect routes
1 parent 46b00b1 commit af32590
Copy full SHA for af32590

File tree

2 files changed

+13
-3
lines changed
Filter options

2 files changed

+13
-3
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public function redirectAction($route, $permanent = false)
4242
return new Response(null, 410);
4343
}
4444

45-
$attributes = $this->container->get('request')->attributes->all();
46-
unset($attributes['_route'], $attributes['route'], $attributes['permanent'] );
45+
$attributes = $this->container->get('request')->attributes->get('_route_params');
46+
unset($attributes['route'], $attributes['permanent']);
4747

4848
return new RedirectResponse($this->container->get('router')->generate($route, $attributes), $permanent ? 301 : 302);
4949
}

‎src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,18 @@ public function testRoute($permanent, $expectedCode)
4646
$route = 'new-route';
4747
$url = '/redirect-url';
4848
$params = array('additional-parameter' => 'value');
49+
$attributes = array(
50+
'route' => $route,
51+
'permanent' => $permanent,
52+
'_route' => 'current-route',
53+
'_route_params' => array(
54+
'route' => $route,
55+
'permanent' => $permanent,
56+
),
57+
);
58+
$attributes['_route_params'] = $attributes['_route_params'] + $params;
4959

50-
$request->attributes = new ParameterBag(array('route' => $route, '_route' => 'current-route', 'permanent' => $permanent) + $params);
60+
$request->attributes = new ParameterBag($attributes);
5161

5262
$router = $this->getMock('Symfony\Component\Routing\RouterInterface');
5363
$router

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.