From 2c7f129aaa5e797b3b88b48fc064d0787077998e Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 8 Dec 2006 08:36:36 +0000 Subject: [PATCH] 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 --- cake/libs/controller/controller.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 49bada63a..b4c2556ce 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -383,18 +383,24 @@ class Controller extends Object { * Redirects to given $url, after turning off $this->autoRender. * Please notice that the script execution is not stopped after the redirect. * - * @param string $url - * @param integer $status + * @param mixed $url A string or array-based URL pointing to another location + * 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 */ - function redirect($url, $status = null) { + function redirect($url, $status = null, $exit = false) { $this->autoRender = false; + if (is_array($status)) { + extract($status, EXTR_OVERWRITE); + } + if (function_exists('session_write_close')) { session_write_close(); } - if ($status != null) { + if (is_numeric($status) && $status > 0) { $codes = array( 100 => "Continue", 101 => "Switching Protocols", @@ -444,6 +450,9 @@ class Controller extends Object { if ($url !== null) { header('Location: ' . Router::url($url, defined('SERVER_IIS'))); } + if ($exit) { + exit(); + } } /** * Saves a variable to use inside a template.