Skip to content

Commit

Permalink
Correctly reuse matched params in PRG
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed Aug 29, 2012
1 parent de807ff commit ad093c6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions library/Zend/Mvc/Controller/Plugin/PostRedirectGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit ad093c6

Please sign in to comment.