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
71782b34
Commit
71782b34
authored
Jun 16, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed existing code to match the changes regarding response
parent
b138199c
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
28 additions
and
25 deletions
+28
-25
SiteController.php
apps/advanced/backend/controllers/SiteController.php
+2
-2
SiteController.php
apps/advanced/frontend/controllers/SiteController.php
+3
-3
SiteController.php
apps/basic/controllers/SiteController.php
+3
-3
Controller.php
framework/yii/base/Controller.php
+1
-1
ErrorHandler.php
framework/yii/base/ErrorHandler.php
+7
-1
CaptchaAction.php
framework/yii/web/CaptchaAction.php
+1
-1
HttpCache.php
framework/yii/web/HttpCache.php
+5
-4
Request.php
framework/yii/web/Request.php
+1
-1
User.php
framework/yii/web/User.php
+4
-5
VerbFilter.php
framework/yii/web/VerbFilter.php
+1
-1
HtmlTest.php
tests/unit/framework/helpers/HtmlTest.php
+0
-3
No files found.
apps/advanced/backend/controllers/SiteController.php
View file @
71782b34
...
@@ -17,7 +17,7 @@ class SiteController extends Controller
...
@@ -17,7 +17,7 @@ class SiteController extends Controller
{
{
$model
=
new
LoginForm
();
$model
=
new
LoginForm
();
if
(
$this
->
populate
(
$_POST
,
$model
)
&&
$model
->
login
())
{
if
(
$this
->
populate
(
$_POST
,
$model
)
&&
$model
->
login
())
{
return
Yii
::
$app
->
response
->
redirect
(
array
(
'site/index'
));
return
$this
->
response
->
redirect
(
array
(
'site/index'
));
}
else
{
}
else
{
return
$this
->
render
(
'login'
,
array
(
return
$this
->
render
(
'login'
,
array
(
'model'
=>
$model
,
'model'
=>
$model
,
...
@@ -28,6 +28,6 @@ class SiteController extends Controller
...
@@ -28,6 +28,6 @@ class SiteController extends Controller
public
function
actionLogout
()
public
function
actionLogout
()
{
{
Yii
::
$app
->
user
->
logout
();
Yii
::
$app
->
user
->
logout
();
return
Yii
::
$app
->
response
->
redirect
(
array
(
'site/index'
));
return
$this
->
response
->
redirect
(
array
(
'site/index'
));
}
}
}
}
apps/advanced/frontend/controllers/SiteController.php
View file @
71782b34
...
@@ -27,7 +27,7 @@ class SiteController extends Controller
...
@@ -27,7 +27,7 @@ class SiteController extends Controller
{
{
$model
=
new
LoginForm
();
$model
=
new
LoginForm
();
if
(
$this
->
populate
(
$_POST
,
$model
)
&&
$model
->
login
())
{
if
(
$this
->
populate
(
$_POST
,
$model
)
&&
$model
->
login
())
{
return
Yii
::
$app
->
response
->
redirect
(
array
(
'site/index'
));
return
$this
->
response
->
redirect
(
array
(
'site/index'
));
}
else
{
}
else
{
return
$this
->
render
(
'login'
,
array
(
return
$this
->
render
(
'login'
,
array
(
'model'
=>
$model
,
'model'
=>
$model
,
...
@@ -38,7 +38,7 @@ class SiteController extends Controller
...
@@ -38,7 +38,7 @@ class SiteController extends Controller
public
function
actionLogout
()
public
function
actionLogout
()
{
{
Yii
::
$app
->
user
->
logout
();
Yii
::
$app
->
user
->
logout
();
return
Yii
::
$app
->
response
->
redirect
(
array
(
'site/index'
));
return
$this
->
response
->
redirect
(
array
(
'site/index'
));
}
}
public
function
actionContact
()
public
function
actionContact
()
...
@@ -46,7 +46,7 @@ class SiteController extends Controller
...
@@ -46,7 +46,7 @@ class SiteController extends Controller
$model
=
new
ContactForm
;
$model
=
new
ContactForm
;
if
(
$this
->
populate
(
$_POST
,
$model
)
&&
$model
->
contact
(
Yii
::
$app
->
params
[
'adminEmail'
]))
{
if
(
$this
->
populate
(
$_POST
,
$model
)
&&
$model
->
contact
(
Yii
::
$app
->
params
[
'adminEmail'
]))
{
Yii
::
$app
->
session
->
setFlash
(
'contactFormSubmitted'
);
Yii
::
$app
->
session
->
setFlash
(
'contactFormSubmitted'
);
return
Yii
::
$app
->
response
->
refresh
();
return
$this
->
response
->
refresh
();
}
else
{
}
else
{
return
$this
->
render
(
'contact'
,
array
(
return
$this
->
render
(
'contact'
,
array
(
'model'
=>
$model
,
'model'
=>
$model
,
...
...
apps/basic/controllers/SiteController.php
View file @
71782b34
...
@@ -27,7 +27,7 @@ class SiteController extends Controller
...
@@ -27,7 +27,7 @@ class SiteController extends Controller
{
{
$model
=
new
LoginForm
();
$model
=
new
LoginForm
();
if
(
$this
->
populate
(
$_POST
,
$model
)
&&
$model
->
login
())
{
if
(
$this
->
populate
(
$_POST
,
$model
)
&&
$model
->
login
())
{
return
Yii
::
$app
->
response
->
redirect
(
array
(
'site/index'
));
return
$this
->
response
->
redirect
(
array
(
'site/index'
));
}
else
{
}
else
{
return
$this
->
render
(
'login'
,
array
(
return
$this
->
render
(
'login'
,
array
(
'model'
=>
$model
,
'model'
=>
$model
,
...
@@ -38,7 +38,7 @@ class SiteController extends Controller
...
@@ -38,7 +38,7 @@ class SiteController extends Controller
public
function
actionLogout
()
public
function
actionLogout
()
{
{
Yii
::
$app
->
user
->
logout
();
Yii
::
$app
->
user
->
logout
();
return
Yii
::
$app
->
response
->
redirect
(
array
(
'site/index'
));
return
$this
->
response
->
redirect
(
array
(
'site/index'
));
}
}
public
function
actionContact
()
public
function
actionContact
()
...
@@ -46,7 +46,7 @@ class SiteController extends Controller
...
@@ -46,7 +46,7 @@ class SiteController extends Controller
$model
=
new
ContactForm
;
$model
=
new
ContactForm
;
if
(
$this
->
populate
(
$_POST
,
$model
)
&&
$model
->
contact
(
Yii
::
$app
->
params
[
'adminEmail'
]))
{
if
(
$this
->
populate
(
$_POST
,
$model
)
&&
$model
->
contact
(
Yii
::
$app
->
params
[
'adminEmail'
]))
{
Yii
::
$app
->
session
->
setFlash
(
'contactFormSubmitted'
);
Yii
::
$app
->
session
->
setFlash
(
'contactFormSubmitted'
);
return
Yii
::
$app
->
response
->
refresh
();
return
$this
->
response
->
refresh
();
}
else
{
}
else
{
return
$this
->
render
(
'contact'
,
array
(
return
$this
->
render
(
'contact'
,
array
(
'model'
=>
$model
,
'model'
=>
$model
,
...
...
framework/yii/base/Controller.php
View file @
71782b34
...
@@ -15,7 +15,7 @@ use Yii;
...
@@ -15,7 +15,7 @@ use Yii;
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
* @since 2.0
*/
*/
class
Controller
extends
Component
abstract
class
Controller
extends
Component
{
{
/**
/**
* @event ActionEvent an event raised right before executing a controller action.
* @event ActionEvent an event raised right before executing a controller action.
...
...
framework/yii/base/ErrorHandler.php
View file @
71782b34
...
@@ -9,6 +9,7 @@ namespace yii\base;
...
@@ -9,6 +9,7 @@ namespace yii\base;
use
Yii
;
use
Yii
;
use
yii\web\HttpException
;
use
yii\web\HttpException
;
use
yii\web\Response
;
/**
/**
* ErrorHandler handles uncaught PHP errors and exceptions.
* ErrorHandler handles uncaught PHP errors and exceptions.
...
@@ -89,8 +90,13 @@ class ErrorHandler extends Component
...
@@ -89,8 +90,13 @@ class ErrorHandler extends Component
$useErrorView
=
!
YII_DEBUG
||
$exception
instanceof
UserException
;
$useErrorView
=
!
YII_DEBUG
||
$exception
instanceof
UserException
;
$response
=
Yii
::
$app
->
getResponse
();
if
(
Yii
::
$app
->
controller
!==
null
)
{
$response
=
Yii
::
$app
->
controller
->
getResponse
();
$response
->
getHeaders
()
->
removeAll
();
$response
->
getHeaders
()
->
removeAll
();
}
if
(
empty
(
$response
))
{
$response
=
new
Response
();
}
if
(
$useErrorView
&&
$this
->
errorAction
!==
null
)
{
if
(
$useErrorView
&&
$this
->
errorAction
!==
null
)
{
$result
=
Yii
::
$app
->
runAction
(
$this
->
errorAction
);
$result
=
Yii
::
$app
->
runAction
(
$this
->
errorAction
);
...
...
framework/yii/web/CaptchaAction.php
View file @
71782b34
...
@@ -325,7 +325,7 @@ class CaptchaAction extends Action
...
@@ -325,7 +325,7 @@ class CaptchaAction extends Action
*/
*/
protected
function
setHttpHeaders
()
protected
function
setHttpHeaders
()
{
{
Yii
::
$app
->
getResponse
()
->
getHeaders
()
$this
->
getResponse
()
->
getHeaders
()
->
set
(
'Pragma'
,
'public'
)
->
set
(
'Pragma'
,
'public'
)
->
set
(
'Expires'
,
'0'
)
->
set
(
'Expires'
,
'0'
)
->
set
(
'Cache-Control'
,
'must-revalidate, post-check=0, pre-check=0'
)
->
set
(
'Cache-Control'
,
'must-revalidate, post-check=0, pre-check=0'
)
...
...
framework/yii/web/HttpCache.php
View file @
71782b34
...
@@ -74,8 +74,8 @@ class HttpCache extends ActionFilter
...
@@ -74,8 +74,8 @@ class HttpCache extends ActionFilter
$etag
=
$this
->
generateEtag
(
$seed
);
$etag
=
$this
->
generateEtag
(
$seed
);
}
}
$
this
->
sendCacheControlHeader
();
$
response
=
$action
->
getResponse
();
$
response
=
Yii
::
$app
->
getResponse
(
);
$
this
->
sendCacheControlHeader
(
$response
);
if
(
$etag
!==
null
)
{
if
(
$etag
!==
null
)
{
$response
->
getHeaders
()
->
set
(
'Etag'
,
$etag
);
$response
->
getHeaders
()
->
set
(
'Etag'
,
$etag
);
}
}
...
@@ -109,12 +109,13 @@ class HttpCache extends ActionFilter
...
@@ -109,12 +109,13 @@ class HttpCache extends ActionFilter
/**
/**
* Sends the cache control header to the client
* Sends the cache control header to the client
* @param Response $response
* @see cacheControl
* @see cacheControl
*/
*/
protected
function
sendCacheControlHeader
()
protected
function
sendCacheControlHeader
(
$response
)
{
{
session_cache_limiter
(
'public'
);
session_cache_limiter
(
'public'
);
$headers
=
Yii
::
$app
->
getResponse
()
->
getHeaders
();
$headers
=
$response
->
getHeaders
();
$headers
->
set
(
'Pragma'
);
$headers
->
set
(
'Pragma'
);
if
(
$this
->
cacheControlHeader
!==
null
)
{
if
(
$this
->
cacheControlHeader
!==
null
)
{
$headers
->
set
(
'Cache-Control'
,
$this
->
cacheControlHeader
);
$headers
->
set
(
'Cache-Control'
,
$this
->
cacheControlHeader
);
...
...
framework/yii/web/Request.php
View file @
71782b34
...
@@ -788,7 +788,7 @@ class Request extends \yii\base\Request
...
@@ -788,7 +788,7 @@ class Request extends \yii\base\Request
$this
->
_csrfCookie
=
$this
->
getCookies
()
->
get
(
$this
->
csrfTokenName
);
$this
->
_csrfCookie
=
$this
->
getCookies
()
->
get
(
$this
->
csrfTokenName
);
if
(
$this
->
_csrfCookie
===
null
)
{
if
(
$this
->
_csrfCookie
===
null
)
{
$this
->
_csrfCookie
=
$this
->
createCsrfCookie
();
$this
->
_csrfCookie
=
$this
->
createCsrfCookie
();
Yii
::
$app
->
getResponse
()
->
getCookies
()
->
add
(
$this
->
_csrfCookie
);
Yii
::
$app
->
controller
->
getResponse
()
->
getCookies
()
->
add
(
$this
->
_csrfCookie
);
}
}
}
}
...
...
framework/yii/web/User.php
View file @
71782b34
...
@@ -283,8 +283,7 @@ class User extends Component
...
@@ -283,8 +283,7 @@ class User extends Component
$this
->
setReturnUrl
(
$request
->
getUrl
());
$this
->
setReturnUrl
(
$request
->
getUrl
());
}
}
if
(
$this
->
loginUrl
!==
null
)
{
if
(
$this
->
loginUrl
!==
null
)
{
$response
=
Yii
::
$app
->
getResponse
();
Yii
::
$app
->
controller
->
getResponse
()
->
redirect
(
$this
->
loginUrl
)
->
send
();
$response
->
redirect
(
$this
->
loginUrl
)
->
send
();
exit
();
exit
();
}
else
{
}
else
{
throw
new
HttpException
(
403
,
Yii
::
t
(
'yii'
,
'Login Required'
));
throw
new
HttpException
(
403
,
Yii
::
t
(
'yii'
,
'Login Required'
));
...
@@ -372,7 +371,7 @@ class User extends Component
...
@@ -372,7 +371,7 @@ class User extends Component
$cookie
=
new
Cookie
(
$this
->
identityCookie
);
$cookie
=
new
Cookie
(
$this
->
identityCookie
);
$cookie
->
value
=
$value
;
$cookie
->
value
=
$value
;
$cookie
->
expire
=
time
()
+
(
int
)
$data
[
2
];
$cookie
->
expire
=
time
()
+
(
int
)
$data
[
2
];
Yii
::
$app
->
getResponse
()
->
getCookies
()
->
add
(
$cookie
);
Yii
::
$app
->
controller
->
getResponse
()
->
getCookies
()
->
add
(
$cookie
);
}
}
}
}
}
}
...
@@ -395,7 +394,7 @@ class User extends Component
...
@@ -395,7 +394,7 @@ class User extends Component
$duration
,
$duration
,
));
));
$cookie
->
expire
=
time
()
+
$duration
;
$cookie
->
expire
=
time
()
+
$duration
;
Yii
::
$app
->
getResponse
()
->
getCookies
()
->
add
(
$cookie
);
Yii
::
$app
->
controller
->
getResponse
()
->
getCookies
()
->
add
(
$cookie
);
}
}
/**
/**
...
@@ -429,7 +428,7 @@ class User extends Component
...
@@ -429,7 +428,7 @@ class User extends Component
$this
->
sendIdentityCookie
(
$identity
,
$duration
);
$this
->
sendIdentityCookie
(
$identity
,
$duration
);
}
}
}
elseif
(
$this
->
enableAutoLogin
)
{
}
elseif
(
$this
->
enableAutoLogin
)
{
Yii
::
$app
->
getResponse
()
->
getCookies
()
->
remove
(
new
Cookie
(
$this
->
identityCookie
));
Yii
::
$app
->
controller
->
getResponse
()
->
getCookies
()
->
remove
(
new
Cookie
(
$this
->
identityCookie
));
}
}
}
}
...
...
framework/yii/web/VerbFilter.php
View file @
71782b34
...
@@ -80,7 +80,7 @@ class VerbFilter extends Behavior
...
@@ -80,7 +80,7 @@ class VerbFilter extends Behavior
if
(
!
in_array
(
$verb
,
$allowed
))
{
if
(
!
in_array
(
$verb
,
$allowed
))
{
$event
->
isValid
=
false
;
$event
->
isValid
=
false
;
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.7
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.7
Yii
::
$app
->
getResponse
()
->
getHeaders
()
->
set
(
'Allow'
,
implode
(
', '
,
$allowed
));
$event
->
action
->
getResponse
()
->
getHeaders
()
->
set
(
'Allow'
,
implode
(
', '
,
$allowed
));
throw
new
HttpException
(
405
,
'Method Not Allowed. This url can only handle the following request methods: '
.
implode
(
', '
,
$allowed
));
throw
new
HttpException
(
405
,
'Method Not Allowed. This url can only handle the following request methods: '
.
implode
(
', '
,
$allowed
));
}
}
}
}
...
...
tests/unit/framework/helpers/HtmlTest.php
View file @
71782b34
...
@@ -17,9 +17,6 @@ class HtmlTest extends TestCase
...
@@ -17,9 +17,6 @@ class HtmlTest extends TestCase
'class'
=>
'yii\web\Request'
,
'class'
=>
'yii\web\Request'
,
'url'
=>
'/test'
,
'url'
=>
'/test'
,
),
),
'response'
=>
array
(
'class'
=>
'yii\web\Response'
,
),
),
),
));
));
}
}
...
...
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