Commit: d4a5a408740a80afd7b9e4f19cd9b2969b9ce21c

Author: Nate Abele | Date: 2010-08-18 11:54:24 -0400
Refactoring `\action\Controller::redirect()` to include more logic in the filter block.
diff --git a/libraries/lithium/action/Controller.php b/libraries/lithium/action/Controller.php index 8985be0..afecc23 100644 --- a/libraries/lithium/action/Controller.php +++ b/libraries/lithium/action/Controller.php @@ -265,10 +265,12 @@ class Controller extends \lithium\core\Object { $router = $this->_classes['router']; $defaults = array('location' => null, 'status' => 302, 'head' => true, 'exit' => true); $options += $defaults; - $options['location'] = $options['location'] ?: $router::match($url, $this->request); + $params = compact('url', 'options'); - $this->_filter(__METHOD__, compact('options'), function($self, $params, $chain) { - $self->render($params['options']); + $this->_filter(__METHOD__, $params, function($self, $params) use ($router) { + $options = $params['options']; + $location = $options['location'] ?: $router::match($params['url'], $self->request); + $self->render(compact('location') + $options); }); if ($options['exit']) {