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
21eab824
Commit
21eab824
authored
Aug 12, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored redirect() methods.
parent
2885d098
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
+8
-8
Controller.php
framework/yii/web/Controller.php
+3
-2
Response.php
framework/yii/web/Response.php
+4
-4
User.php
framework/yii/web/User.php
+1
-2
No files found.
framework/yii/web/Controller.php
View file @
21eab824
...
...
@@ -9,6 +9,7 @@ namespace yii\web;
use
Yii
;
use
yii\base\InlineAction
;
use
yii\helpers\Html
;
/**
* Controller is the base class of Web controllers.
...
...
@@ -95,7 +96,7 @@ class Controller extends \yii\base\Controller
* Redirects the browser to the specified URL.
* This method is a shortcut to [[Response::redirect()]].
*
* @param array|string $url the URL to be redirected to. [[
\yii\helpers\
Html::url()]]
* @param array|string $url the URL to be redirected to. [[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 integer $statusCode the HTTP status code. If null, it will use 302
...
...
@@ -106,7 +107,7 @@ class Controller extends \yii\base\Controller
*/
public
function
redirect
(
$url
,
$statusCode
=
null
)
{
return
Yii
::
$app
->
getResponse
()
->
redirect
(
$url
,
$statusCode
);
return
Yii
::
$app
->
getResponse
()
->
redirect
(
Html
::
url
(
$url
)
,
$statusCode
);
}
/**
...
...
framework/yii/web/Response.php
View file @
21eab824
...
...
@@ -563,9 +563,9 @@ class Response extends \yii\base\Response
* return Yii::$app->getResponse()->redirect($url);
* ~~~
*
* @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
string $url the URL to be redirected to. This can be a URL or an alias of the URL.
*
The URL can be either relative or absolute. If relative, the host info of the current request
*
will be prepend to the URL
.
* @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]]
...
...
@@ -574,7 +574,7 @@ class Response extends \yii\base\Response
*/
public
function
redirect
(
$url
,
$statusCode
=
null
)
{
$url
=
Html
::
url
(
$url
);
$url
=
Yii
::
getAlias
(
$url
);
if
(
strpos
(
$url
,
'/'
)
===
0
&&
strpos
(
$url
,
'//'
)
!==
0
)
{
$url
=
Yii
::
$app
->
getRequest
()
->
getHostInfo
()
.
$url
;
}
...
...
framework/yii/web/User.php
View file @
21eab824
...
...
@@ -283,8 +283,7 @@ class User extends Component
$this
->
setReturnUrl
(
$request
->
getUrl
());
}
if
(
$this
->
loginUrl
!==
null
)
{
$response
=
Yii
::
$app
->
getResponse
();
$response
->
redirect
(
$this
->
loginUrl
)
->
send
();
Yii
::
$app
->
getResponse
()
->
redirect
(
$this
->
loginUrl
)
->
send
();
exit
();
}
else
{
throw
new
HttpException
(
403
,
Yii
::
t
(
'yii'
,
'Login Required'
));
...
...
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