mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
a7d07aea20
commit
2c7f129aaa
1 changed files with 13 additions and 4 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue