Permalink
Browse files

Correctly reuse matched params in PRG

  • Loading branch information...
1 parent de807ff commit ad093c6f63fd37533ba7c4713766e521cf2b7d0d @bakura10 committed Aug 29, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 library/Zend/Mvc/Controller/Plugin/PostRedirectGet.php
@@ -27,9 +27,13 @@ public function __invoke($redirect = null, $redirectToUrl = false)
{
$controller = $this->getController();
$request = $controller->getRequest();
+ $params = array();
if (null === $redirect) {
- $redirect = $controller->getEvent()->getRouteMatch()->getMatchedRouteName();
+ $routeMatch = $controller->getEvent()->getRouteMatch();
+
+ $redirect = $routeMatch->getMatchedRouteName();
+ $params = $routeMatch->getParams();
}
$container = new Container('prg_post1');
@@ -42,9 +46,8 @@ public function __invoke($redirect = null, $redirectToUrl = false)
// get the redirect plugin from the plugin manager
$redirector = $controller->getPluginManager()->get('Redirect');
} else {
-
/*
- * if the user wants to redirect to a route, the redirector has to come
+ * If the user wants to redirect to a route, the redirector has to come
* from the plugin manager -- otherwise no router will be injected
*/
if ($redirectToUrl === false) {
@@ -55,13 +58,14 @@ public function __invoke($redirect = null, $redirectToUrl = false)
}
if ($redirectToUrl === false) {
- $response = $redirector->toRoute($redirect);
+ $response = $redirector->toRoute($redirect, $params);
$response->setStatusCode(303);
return $response;
}
$response = $redirector->toUrl($redirect);
$response->setStatusCode(303);
+
return $response;
} else {
if ($container->post !== null) {

0 comments on commit ad093c6

Please sign in to comment.