From af3259026d21a48b92b2ef7f65e409f7968a5c9f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 9 Jan 2012 21:29:20 +0100 Subject: [PATCH] [FrameworkBundle] Use only _route_params to generate redirect routes --- .../Controller/RedirectController.php | 4 ++-- .../Tests/Controller/RedirectControllerTest.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index 2e2a24a091..6d62c9abfc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -42,8 +42,8 @@ class RedirectController extends ContainerAware return new Response(null, 410); } - $attributes = $this->container->get('request')->attributes->all(); - unset($attributes['_route'], $attributes['route'], $attributes['permanent'] ); + $attributes = $this->container->get('request')->attributes->get('_route_params'); + unset($attributes['route'], $attributes['permanent']); return new RedirectResponse($this->container->get('router')->generate($route, $attributes), $permanent ? 301 : 302); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php index e90f9dc25a..681cd0a59d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php @@ -46,8 +46,18 @@ class RedirectControllerTest extends TestCase $route = 'new-route'; $url = '/redirect-url'; $params = array('additional-parameter' => 'value'); + $attributes = array( + 'route' => $route, + 'permanent' => $permanent, + '_route' => 'current-route', + '_route_params' => array( + 'route' => $route, + 'permanent' => $permanent, + ), + ); + $attributes['_route_params'] = $attributes['_route_params'] + $params; - $request->attributes = new ParameterBag(array('route' => $route, '_route' => 'current-route', 'permanent' => $permanent) + $params); + $request->attributes = new ParameterBag($attributes); $router = $this->getMock('Symfony\Component\Routing\RouterInterface'); $router