Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
d19446ba
Commit
d19446ba
authored
Jun 11, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor adjustment of Response::redirect()
parent
9d3c9db4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
Response.php
framework/yii/web/Response.php
+10
-10
No files found.
framework/yii/web/Response.php
View file @
d19446ba
...
...
@@ -498,20 +498,20 @@ class Response extends \yii\base\Response
* @param array|string $url the URL to be redirected to. [[\yii\helpers\Html::url()]]
* will be used to normalize the URL. If the resulting URL is still a relative URL
* (one without host info), the current request host info will be used.
* @param
boolean $terminate whether to terminate the current application
*
@param integer $statusCode the HTTP status code. Defaults to 302
.
* @param
integer $statusCode the HTTP status code. If null, it will use 302
*
for normal requests, and [[ajaxRedirectCode]] for AJAX requests
.
* See [[http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html]]
* for details about HTTP status code
.
*
Note that if the request is an AJAX request, [[ajaxRedirectCode]] will be used instead.
* for details about HTTP status code
*
@param boolean $terminate whether to terminate the current application
*/
public
function
redirect
(
$url
,
$
terminate
=
true
,
$statusCode
=
302
)
public
function
redirect
(
$url
,
$
statusCode
=
null
,
$terminate
=
true
)
{
$url
=
Html
::
url
(
$url
);
if
(
strpos
(
$url
,
'/'
)
===
0
&&
strpos
(
$url
,
'//'
)
!==
0
)
{
$url
=
Yii
::
$app
->
getRequest
()
->
getHostInfo
()
.
$url
;
}
if
(
Yii
::
$app
->
getRequest
()
->
getIsAjax
()
)
{
$statusCode
=
$this
->
ajaxRedirectCode
;
if
(
$statusCode
===
null
)
{
$statusCode
=
Yii
::
$app
->
getRequest
()
->
getIsAjax
()
?
$this
->
ajaxRedirectCode
:
302
;
}
$this
->
getHeaders
()
->
set
(
'Location'
,
$url
);
$this
->
setStatusCode
(
$statusCode
);
...
...
@@ -615,7 +615,7 @@ class Response extends \yii\base\Response
*/
public
function
getIsOk
()
{
return
200
===
$this
->
getStatusCode
()
;
return
$this
->
getStatusCode
()
==
200
;
}
/**
...
...
@@ -623,7 +623,7 @@ class Response extends \yii\base\Response
*/
public
function
getIsForbidden
()
{
return
403
===
$this
->
getStatusCode
()
;
return
$this
->
getStatusCode
()
==
403
;
}
/**
...
...
@@ -631,7 +631,7 @@ class Response extends \yii\base\Response
*/
public
function
getIsNotFound
()
{
return
404
===
$this
->
getStatusCode
()
;
return
$this
->
getStatusCode
()
==
404
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment