Adding 3rd param to Controller::redirect to allow auto-exiting

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4082 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-12-08 08:36:36 +00:00
parent a7d07aea20
commit 2c7f129aaa

View file

@ -383,18 +383,24 @@ class Controller extends Object {
* Redirects to given $url, after turning off $this->autoRender. * Redirects to given $url, after turning off $this->autoRender.
* Please notice that the script execution is not stopped after the redirect. * Please notice that the script execution is not stopped after the redirect.
* *
* @param string $url * @param mixed $url A string or array-based URL pointing to another location
* @param integer $status * within the app, or an absolute URL
* @param integer $status Optional HTTP status code
* @param boolean $exit If true, exit() will be called after the redirect
* @access public * @access public
*/ */
function redirect($url, $status = null) { function redirect($url, $status = null, $exit = false) {
$this->autoRender = false; $this->autoRender = false;
if (is_array($status)) {
extract($status, EXTR_OVERWRITE);
}
if (function_exists('session_write_close')) { if (function_exists('session_write_close')) {
session_write_close(); session_write_close();
} }
if ($status != null) { if (is_numeric($status) && $status > 0) {
$codes = array( $codes = array(
100 => "Continue", 100 => "Continue",
101 => "Switching Protocols", 101 => "Switching Protocols",
@ -444,6 +450,9 @@ class Controller extends Object {
if ($url !== null) { if ($url !== null) {
header('Location: ' . Router::url($url, defined('SERVER_IIS'))); header('Location: ' . Router::url($url, defined('SERVER_IIS')));
} }
if ($exit) {
exit();
}
} }
/** /**
* Saves a variable to use inside a template. * Saves a variable to use inside a template.