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
2d866186
Commit
2d866186
authored
11 years ago
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:yiisoft/yii2
parents
2f8ee2a8
0eaafd74
master
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
90 changed files
with
483 additions
and
211 deletions
+483
-211
main.php
apps/advanced/backend/config/main.php
+3
-3
SiteController.php
apps/advanced/backend/controllers/SiteController.php
+1
-1
main.php
apps/advanced/backend/views/layouts/main.php
+4
-4
SiteController.php
apps/advanced/frontend/controllers/SiteController.php
+1
-1
passwordResetToken.php
apps/advanced/frontend/views/emails/passwordResetToken.php
+2
-2
main.php
apps/advanced/frontend/views/layouts/main.php
+6
-6
login.php
apps/advanced/frontend/views/site/login.php
+1
-1
main.php
apps/basic/views/layouts/main.php
+7
-6
composer.json
extensions/bootstrap/composer.json
+6
-1
composer.json
extensions/composer/composer.json
+0
-1
composer.json
extensions/debug/composer.json
+6
-1
composer.json
extensions/gii/composer.json
+6
-1
index.php
extensions/gii/views/default/index.php
+4
-4
files.php
extensions/gii/views/default/view/files.php
+2
-2
generator.php
extensions/gii/views/layouts/generator.php
+4
-4
main.php
extensions/gii/views/layouts/main.php
+2
-2
composer.json
extensions/jui/composer.json
+6
-1
composer.json
extensions/smarty/composer.json
+1
-2
Message.php
extensions/swiftmailer/Message.php
+1
-1
composer.json
extensions/swiftmailer/composer.json
+1
-2
composer.json
extensions/twig/composer.json
+1
-2
composer.json
framework/composer.json
+2
-2
BaseYii.php
framework/yii/BaseYii.php
+9
-10
ActionFilter.php
framework/yii/base/ActionFilter.php
+5
-0
Application.php
framework/yii/base/Application.php
+0
-2
Component.php
framework/yii/base/Component.php
+10
-8
Controller.php
framework/yii/base/Controller.php
+2
-3
ErrorHandler.php
framework/yii/base/ErrorHandler.php
+3
-0
Formatter.php
framework/yii/base/Formatter.php
+3
-0
Model.php
framework/yii/base/Model.php
+13
-13
Module.php
framework/yii/base/Module.php
+1
-1
Object.php
framework/yii/base/Object.php
+9
-6
Request.php
framework/yii/base/Request.php
+1
-0
Response.php
framework/yii/base/Response.php
+2
-0
View.php
framework/yii/base/View.php
+2
-2
ViewEvent.php
framework/yii/base/ViewEvent.php
+2
-0
CaptchaAsset.php
framework/yii/captcha/CaptchaAsset.php
+2
-0
Request.php
framework/yii/console/Request.php
+4
-0
Response.php
framework/yii/console/Response.php
+2
-0
CacheController.php
framework/yii/console/controllers/CacheController.php
+1
-1
ActiveQuery.php
framework/yii/db/ActiveQuery.php
+3
-3
ActiveRecord.php
framework/yii/db/ActiveRecord.php
+11
-11
ActiveRelation.php
framework/yii/db/ActiveRelation.php
+7
-5
Command.php
framework/yii/db/Command.php
+1
-1
Query.php
framework/yii/db/Query.php
+2
-2
Schema.php
framework/yii/db/Schema.php
+4
-4
ActionColumn.php
framework/yii/grid/ActionColumn.php
+2
-0
DataColumn.php
framework/yii/grid/DataColumn.php
+4
-0
GridView.php
framework/yii/grid/GridView.php
+4
-0
GridViewAsset.php
framework/yii/grid/GridViewAsset.php
+1
-0
BaseHtml.php
framework/yii/helpers/BaseHtml.php
+13
-13
BaseInflector.php
framework/yii/helpers/BaseInflector.php
+1
-1
Formatter.php
framework/yii/i18n/Formatter.php
+9
-0
I18N.php
framework/yii/i18n/I18N.php
+3
-0
Target.php
framework/yii/log/Target.php
+1
-1
BaseMailer.php
framework/yii/mail/BaseMailer.php
+1
-1
PhpManager.php
framework/yii/rbac/PhpManager.php
+14
-14
requirements.php
framework/yii/requirements/requirements.php
+1
-1
index.php
framework/yii/requirements/views/console/index.php
+3
-3
index.php
framework/yii/requirements/views/web/index.php
+3
-3
ExistValidator.php
framework/yii/validators/ExistValidator.php
+2
-2
PunycodeAsset.php
framework/yii/validators/PunycodeAsset.php
+2
-0
UniqueValidator.php
framework/yii/validators/UniqueValidator.php
+1
-1
ValidationAsset.php
framework/yii/validators/ValidationAsset.php
+2
-0
AccessControl.php
framework/yii/web/AccessControl.php
+1
-1
AssetConverter.php
framework/yii/web/AssetConverter.php
+4
-0
AssetManager.php
framework/yii/web/AssetManager.php
+16
-0
CacheSession.php
framework/yii/web/CacheSession.php
+11
-1
Controller.php
framework/yii/web/Controller.php
+31
-0
DbSession.php
framework/yii/web/DbSession.php
+1
-0
HttpCache.php
framework/yii/web/HttpCache.php
+26
-1
HttpException.php
framework/yii/web/HttpException.php
+8
-0
PageCache.php
framework/yii/web/PageCache.php
+30
-0
Request.php
framework/yii/web/Request.php
+12
-9
Response.php
framework/yii/web/Response.php
+14
-0
Session.php
framework/yii/web/Session.php
+2
-1
UploadedFile.php
framework/yii/web/UploadedFile.php
+1
-1
UrlManager.php
framework/yii/web/UrlManager.php
+19
-3
UrlRule.php
framework/yii/web/UrlRule.php
+11
-1
User.php
framework/yii/web/User.php
+21
-6
View.php
framework/yii/web/View.php
+23
-7
XmlResponseFormatter.php
framework/yii/web/XmlResponseFormatter.php
+2
-0
YiiAsset.php
framework/yii/web/YiiAsset.php
+2
-0
ActiveForm.php
framework/yii/widgets/ActiveForm.php
+1
-1
Menu.php
framework/yii/widgets/Menu.php
+3
-3
layout.php
tests/unit/data/views/layout.php
+3
-4
rawlayout.php
tests/unit/data/views/rawlayout.php
+2
-3
MessageTest.php
tests/unit/extensions/swiftmailer/MessageTest.php
+1
-1
ActiveRecordTest.php
tests/unit/framework/db/ActiveRecordTest.php
+3
-3
ValidatorTest.php
tests/unit/framework/validators/ValidatorTest.php
+2
-3
No files found.
apps/advanced/backend/config/main.php
View file @
2d866186
<?php
$rootDir
=
__DIR__
.
'/../..'
;
$rootDir
=
dirname
(
dirname
(
__DIR__
))
;
$params
=
array_merge
(
require
(
$rootDir
.
'/common/config/params.php'
),
...
...
@@ -11,11 +11,11 @@ $params = array_merge(
return
[
'id'
=>
'app-backend'
,
'basePath'
=>
dirname
(
__DIR__
),
'vendorPath'
=>
dirname
(
dirname
(
__DIR__
))
.
'/vendor'
,
'vendorPath'
=>
$rootDir
.
'/vendor'
,
'preload'
=>
[
'log'
],
'controllerNamespace'
=>
'backend\controllers'
,
'modules'
=>
[],
'extensions'
=>
require
(
__DIR__
.
'/../..
/vendor/yiisoft/extensions.php'
),
'extensions'
=>
require
(
$rootDir
.
'
/vendor/yiisoft/extensions.php'
),
'components'
=>
[
'request'
=>
[
'enableCsrfValidation'
=>
true
,
...
...
This diff is collapsed.
Click to expand it.
apps/advanced/backend/controllers/SiteController.php
View file @
2d866186
...
...
@@ -50,7 +50,7 @@ class SiteController extends Controller
$model
=
new
LoginForm
();
if
(
$model
->
load
(
$_POST
)
&&
$model
->
login
())
{
return
$this
->
go
Home
();
return
$this
->
go
Back
();
}
else
{
return
$this
->
render
(
'login'
,
[
'model'
=>
$model
,
...
...
This diff is collapsed.
Click to expand it.
apps/advanced/backend/views/layouts/main.php
View file @
2d866186
...
...
@@ -6,8 +6,8 @@ use yii\bootstrap\NavBar;
use
yii\widgets\Breadcrumbs
;
/**
* @var
$this \yii\web\View
* @var
$content string
* @var
\yii\web\View $this
* @var
string $content
*/
AppAsset
::
register
(
$this
);
?>
...
...
@@ -45,9 +45,9 @@ AppAsset::register($this);
?>
<div
class=
"container"
>
<?=
Breadcrumbs
::
widget
([
<?=
Breadcrumbs
::
widget
([
'links'
=>
isset
(
$this
->
params
[
'breadcrumbs'
])
?
$this
->
params
[
'breadcrumbs'
]
:
[],
])
;
?>
])
?>
<?=
$content
?>
</div>
...
...
This diff is collapsed.
Click to expand it.
apps/advanced/frontend/controllers/SiteController.php
View file @
2d866186
...
...
@@ -60,7 +60,7 @@ class SiteController extends Controller
$model
=
new
LoginForm
();
if
(
$model
->
load
(
$_POST
)
&&
$model
->
login
())
{
return
$this
->
go
Home
();
return
$this
->
go
Back
();
}
else
{
return
$this
->
render
(
'login'
,
[
'model'
=>
$model
,
...
...
This diff is collapsed.
Click to expand it.
apps/advanced/frontend/views/emails/passwordResetToken.php
View file @
2d866186
...
...
@@ -9,8 +9,8 @@ use yii\helpers\Html;
$resetLink
=
Yii
::
$app
->
urlManager
->
createAbsoluteUrl
(
'site/reset-password'
,
[
'token'
=>
$user
->
password_reset_token
]);
?>
Hello
<?=
Html
::
encode
(
$user
->
username
)
?>
,
Hello
<?=
Html
::
encode
(
$user
->
username
)
?>
,
Follow the link below to reset your password:
<?=
Html
::
a
(
Html
::
encode
(
$resetLink
),
$resetLink
)
?>
<?=
Html
::
a
(
Html
::
encode
(
$resetLink
),
$resetLink
)
?>
This diff is collapsed.
Click to expand it.
apps/advanced/frontend/views/layouts/main.php
View file @
2d866186
<?php
use
frontend\config\AppAsset
;
use
yii\helpers\Html
;
use
yii\bootstrap\Nav
;
use
yii\bootstrap\NavBar
;
use
yii\widgets\Breadcrumbs
;
use
frontend\config\AppAsset
;
use
frontend\widgets\Alert
;
/**
* @var
$this \yii\web\View
* @var
$content string
* @var
\yii\web\View $this
* @var
string $content
*/
AppAsset
::
register
(
$this
);
?>
...
...
@@ -49,10 +49,10 @@ AppAsset::register($this);
?>
<div
class=
"container"
>
<?=
Breadcrumbs
::
widget
([
<?=
Breadcrumbs
::
widget
([
'links'
=>
isset
(
$this
->
params
[
'breadcrumbs'
])
?
$this
->
params
[
'breadcrumbs'
]
:
[],
])
;
?>
<?=
Alert
::
widget
()
?>
])
?>
<?=
Alert
::
widget
()
?>
<?=
$content
?>
</div>
...
...
This diff is collapsed.
Click to expand it.
apps/advanced/frontend/views/site/login.php
View file @
2d866186
...
...
@@ -22,7 +22,7 @@ $this->params['breadcrumbs'][] = $this->title;
<?=
$form
->
field
(
$model
,
'password'
)
->
passwordInput
()
?>
<?=
$form
->
field
(
$model
,
'rememberMe'
)
->
checkbox
()
?>
<div
style=
"color:#999;margin:1em 0"
>
If you forgot your password you can
<?=
Html
::
a
(
'reset it'
,
[
'site/request-password-reset'
])
?>
.
If you forgot your password you can
<?=
Html
::
a
(
'reset it'
,
[
'site/request-password-reset'
])
?>
.
</div>
<div
class=
"form-group"
>
<?=
Html
::
submitButton
(
'Login'
,
[
'class'
=>
'btn btn-primary'
])
?>
...
...
This diff is collapsed.
Click to expand it.
apps/basic/views/layouts/main.php
View file @
2d866186
...
...
@@ -3,12 +3,13 @@ use yii\helpers\Html;
use
yii\bootstrap\Nav
;
use
yii\bootstrap\NavBar
;
use
yii\widgets\Breadcrumbs
;
use
app\config\AppAsset
;
/**
* @var
$this \yii\web\View
* @var
$content string
* @var
\yii\web\View $this
* @var
string $content
*/
app\config\
AppAsset
::
register
(
$this
);
AppAsset
::
register
(
$this
);
?>
<?php
$this
->
beginPage
();
?>
<!DOCTYPE html>
...
...
@@ -36,7 +37,7 @@ app\config\AppAsset::register($this);
[
'label'
=>
'Contact'
,
'url'
=>
[
'/site/contact'
]],
Yii
::
$app
->
user
->
isGuest
?
[
'label'
=>
'Login'
,
'url'
=>
[
'/site/login'
]]
:
[
'label'
=>
'Logout ('
.
Yii
::
$app
->
user
->
identity
->
username
.
')'
,
[
'label'
=>
'Logout ('
.
Yii
::
$app
->
user
->
identity
->
username
.
')'
,
'url'
=>
[
'/site/logout'
],
'linkOptions'
=>
[
'data-method'
=>
'post'
]],
],
...
...
@@ -45,9 +46,9 @@ app\config\AppAsset::register($this);
?>
<div
class=
"container"
>
<?=
Breadcrumbs
::
widget
([
<?=
Breadcrumbs
::
widget
([
'links'
=>
isset
(
$this
->
params
[
'breadcrumbs'
])
?
$this
->
params
[
'breadcrumbs'
]
:
[],
])
;
?>
])
?>
<?=
$content
?>
</div>
...
...
This diff is collapsed.
Click to expand it.
extensions/bootstrap/composer.json
View file @
2d866186
...
...
@@ -11,7 +11,12 @@
"irc"
:
"irc://irc.freenode.net/yii"
,
"source"
:
"https://github.com/yiisoft/yii2"
},
"minimum-stability"
:
"dev"
,
"authors"
:
[
{
"name"
:
"Qiang Xue"
,
"email"
:
"qiang.xue@gmail.com"
}
],
"require"
:
{
"yiisoft/yii2"
:
"*"
,
"twbs/bootstrap"
:
"3.0.*"
...
...
This diff is collapsed.
Click to expand it.
extensions/composer/composer.json
View file @
2d866186
...
...
@@ -17,7 +17,6 @@
"email"
:
"qiang.xue@gmail.com"
}
],
"minimum-stability"
:
"dev"
,
"autoload"
:
{
"psr-0"
:
{
"yii
\\
composer
\\
"
:
""
}
},
...
...
This diff is collapsed.
Click to expand it.
extensions/debug/composer.json
View file @
2d866186
...
...
@@ -11,7 +11,12 @@
"irc"
:
"irc://irc.freenode.net/yii"
,
"source"
:
"https://github.com/yiisoft/yii2"
},
"minimum-stability"
:
"dev"
,
"authors"
:
[
{
"name"
:
"Qiang Xue"
,
"email"
:
"qiang.xue@gmail.com"
}
],
"require"
:
{
"yiisoft/yii2"
:
"*"
,
"yiisoft/yii2-bootstrap"
:
"*"
...
...
This diff is collapsed.
Click to expand it.
extensions/gii/composer.json
View file @
2d866186
...
...
@@ -11,7 +11,12 @@
"irc"
:
"irc://irc.freenode.net/yii"
,
"source"
:
"https://github.com/yiisoft/yii2"
},
"minimum-stability"
:
"dev"
,
"authors"
:
[
{
"name"
:
"Qiang Xue"
,
"email"
:
"qiang.xue@gmail.com"
}
],
"require"
:
{
"yiisoft/yii2"
:
"*"
,
"yiisoft/yii2-bootstrap"
:
"*"
...
...
This diff is collapsed.
Click to expand it.
extensions/gii/views/default/index.php
View file @
2d866186
...
...
@@ -2,10 +2,10 @@
use
yii\helpers\Html
;
/**
* @var
$this \yii\web\View
* @var
$content string
* @var
yii\gii\Generator[] $generators
* @var
yii\gii\Generator $activeGenerator
* @var
\yii\web\View $this
* @var
\yii\gii\Generator[] $generators
* @var
\yii\gii\Generator $activeGenerator
* @var
string $content
*/
$generators
=
Yii
::
$app
->
controller
->
module
->
generators
;
$activeGenerator
=
Yii
::
$app
->
controller
->
generator
;
...
...
This diff is collapsed.
Click to expand it.
extensions/gii/views/default/view/files.php
View file @
2d866186
...
...
@@ -4,8 +4,8 @@ use yii\helpers\Html;
use
yii\gii\CodeFile
;
/**
* @var
$this \yii\web\View
* @var
$generator \yii\gii\G
enerator
* @var
\yii\web\View $this
* @var
\yii\gii\Generator $g
enerator
* @var CodeFile[] $files
* @var array $answers
*/
...
...
This diff is collapsed.
Click to expand it.
extensions/gii/views/layouts/generator.php
View file @
2d866186
...
...
@@ -2,10 +2,10 @@
use
yii\helpers\Html
;
/**
* @var
$this \yii\web\View
* @var
$content string
* @var
yii\gii\Generator[] $generators
* @var
yii\gii\Generator $activeGenerator
* @var
\yii\web\View $this
* @var
\yii\gii\Generator[] $generators
* @var
\yii\gii\Generator $activeGenerator
* @var
string $content
*/
$generators
=
Yii
::
$app
->
controller
->
module
->
generators
;
$activeGenerator
=
Yii
::
$app
->
controller
->
generator
;
...
...
This diff is collapsed.
Click to expand it.
extensions/gii/views/layouts/main.php
View file @
2d866186
...
...
@@ -4,8 +4,8 @@ use yii\bootstrap\Nav;
use
yii\helpers\Html
;
/**
* @var
$this \yii\web\View
* @var
$content string
* @var
\yii\web\View $this
* @var
string $content
*/
$asset
=
yii\gii\GiiAsset
::
register
(
$this
);
?>
...
...
This diff is collapsed.
Click to expand it.
extensions/jui/composer.json
View file @
2d866186
...
...
@@ -11,7 +11,12 @@
"irc"
:
"irc://irc.freenode.net/yii"
,
"source"
:
"https://github.com/yiisoft/yii2"
},
"minimum-stability"
:
"dev"
,
"authors"
:
[
{
"name"
:
"Qiang Xue"
,
"email"
:
"qiang.xue@gmail.com"
}
],
"require"
:
{
"yiisoft/yii2"
:
"*"
},
...
...
This diff is collapsed.
Click to expand it.
extensions/smarty/composer.json
View file @
2d866186
...
...
@@ -17,10 +17,9 @@
"email"
:
"sam@rmcreative.ru"
}
],
"minimum-stability"
:
"dev"
,
"require"
:
{
"yiisoft/yii2"
:
"*"
,
"smarty/smarty"
:
"
>=v3.1.13
"
"smarty/smarty"
:
"
*
"
},
"autoload"
:
{
"psr-0"
:
{
"yii
\\
smarty
\\
"
:
""
}
...
...
This diff is collapsed.
Click to expand it.
extensions/swiftmailer/Message.php
View file @
2d866186
...
...
@@ -192,7 +192,7 @@ class Message extends BaseMessage
$partFound
=
false
;
foreach
(
$parts
as
$key
=>
$part
)
{
if
(
!
(
$part
instanceof
\Swift_Mime_Attachment
))
{
/* @var
$part \Swift_Mime_MimeP
art */
/* @var
\Swift_Mime_MimePart $p
art */
if
(
$part
->
getContentType
()
==
$contentType
)
{
unset
(
$parts
[
$key
]);
$partFound
=
true
;
...
...
This diff is collapsed.
Click to expand it.
extensions/swiftmailer/composer.json
View file @
2d866186
...
...
@@ -17,10 +17,9 @@
"email"
:
"klimov.paul@gmail.com"
}
],
"minimum-stability"
:
"dev"
,
"require"
:
{
"yiisoft/yii2"
:
"*"
,
"swiftmailer/swiftmailer"
:
"
@stable
"
"swiftmailer/swiftmailer"
:
"
*
"
},
"autoload"
:
{
"psr-0"
:
{
"yii
\\
swiftmailer
\\
"
:
""
}
...
...
This diff is collapsed.
Click to expand it.
extensions/twig/composer.json
View file @
2d866186
...
...
@@ -17,10 +17,9 @@
"email"
:
"sam@rmcreative.ru"
}
],
"minimum-stability"
:
"dev"
,
"require"
:
{
"yiisoft/yii2"
:
"*"
,
"twig/twig"
:
"
1.13.
*"
"twig/twig"
:
"*"
},
"autoload"
:
{
"psr-0"
:
{
"yii
\\
twig
\\
"
:
""
}
...
...
This diff is collapsed.
Click to expand it.
framework/composer.json
View file @
2d866186
...
...
@@ -65,10 +65,10 @@
},
"require"
:
{
"php"
:
">=5.4.0"
,
"yiisoft/yii2-composer"
:
"*"
,
"yiisoft/jquery"
:
"1.10.*"
,
"ext-mbstring"
:
"*"
,
"lib-pcre"
:
"*"
,
"yiisoft/yii2-composer"
:
"*"
,
"yiisoft/jquery"
:
"1.10.*"
,
"phpspec/php-diff"
:
">=1.0.2"
,
"ezyang/htmlpurifier"
:
"4.5.*"
,
"michelf/php-markdown"
:
"1.3.*"
...
...
This diff is collapsed.
Click to expand it.
framework/yii/BaseYii.php
View file @
2d866186
...
...
@@ -63,8 +63,7 @@ class BaseYii
* The array keys are the class names (without leading backslashes), and the array values
* are the corresponding class file paths (or path aliases). This property mainly affects
* how [[autoload()]] works.
* @see import
* @see autoload
* @see autoload()
*/
public
static
$classMap
=
[];
/**
...
...
@@ -73,8 +72,8 @@ class BaseYii
public
static
$app
;
/**
* @var array registered path aliases
* @see getAlias
* @see setAlias
* @see getAlias
()
* @see setAlias
()
*/
public
static
$aliases
=
[
'@yii'
=>
__DIR__
];
/**
...
...
@@ -95,7 +94,7 @@ class BaseYii
* ]
* ~~~
*
* @see createObject
* @see createObject
()
*/
public
static
$objectConfig
=
[];
...
...
@@ -136,7 +135,7 @@ class BaseYii
* If this is false and an invalid alias is given, false will be returned by this method.
* @return string|boolean the path corresponding to the alias, false if the root alias is not previously registered.
* @throws InvalidParamException if the alias is invalid while $throwException is true.
* @see setAlias
* @see setAlias
()
*/
public
static
function
getAlias
(
$alias
,
$throwException
=
true
)
{
...
...
@@ -219,7 +218,7 @@ class BaseYii
* actual path first by calling [[getAlias()]].
*
* @throws InvalidParamException if $path is an invalid alias.
* @see getAlias
* @see getAlias
()
*/
public
static
function
setAlias
(
$alias
,
$path
)
{
...
...
@@ -368,7 +367,7 @@ class BaseYii
}
if
((
$n
=
func_num_args
())
>
1
)
{
/** @var
$reflection \ReflectionClass
*/
/** @var
\ReflectionClass $reflection
*/
if
(
isset
(
$reflections
[
$class
]))
{
$reflection
=
$reflections
[
$class
];
}
else
{
...
...
@@ -450,7 +449,7 @@ class BaseYii
* ~~~
* @param string $token token for the code block
* @param string $category the category of this log message
* @see endProfile
* @see endProfile
()
*/
public
static
function
beginProfile
(
$token
,
$category
=
'application'
)
{
...
...
@@ -462,7 +461,7 @@ class BaseYii
* This has to be matched with a previous call to [[beginProfile]] with the same category name.
* @param string $token token for the code block
* @param string $category the category of this log message
* @see beginProfile
* @see beginProfile
()
*/
public
static
function
endProfile
(
$token
,
$category
=
'application'
)
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/ActionFilter.php
View file @
2d866186
...
...
@@ -8,6 +8,11 @@
namespace
yii\base
;
/**
* ActionFilter provides a base implementation for action filters that can be added to a controller
* to handle the `beforeAction` event.
*
* Check implementation of [[AccessControl]], [[PageCache]] and [[HttpCache]] as examples on how to use it.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/Application.php
View file @
2d866186
...
...
@@ -616,10 +616,8 @@ abstract class Application extends Module
{
$category
=
get_class
(
$exception
);
if
(
$exception
instanceof
HttpException
)
{
/** @var $exception HttpException */
$category
.=
'\\'
.
$exception
->
statusCode
;
}
elseif
(
$exception
instanceof
\ErrorException
)
{
/** @var $exception \ErrorException */
$category
.=
'\\'
.
$exception
->
getSeverity
();
}
Yii
::
error
((
string
)
$exception
,
$category
);
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/Component.php
View file @
2d866186
...
...
@@ -10,6 +10,8 @@ namespace yii\base;
use
Yii
;
/**
* Component is the base class that implements the *property*, *event* and *behavior* features.
*
* @include @yii/base/Component.md
*
* @property Behavior[] $behaviors List of behaviors attached to this component. This property is read-only.
...
...
@@ -41,7 +43,7 @@ class Component extends Object
* @return mixed the property value or the value of a behavior's property
* @throws UnknownPropertyException if the property is not defined
* @throws InvalidCallException if the property is write-only.
* @see __set
* @see __set
()
*/
public
function
__get
(
$name
)
{
...
...
@@ -80,7 +82,7 @@ class Component extends Object
* @param mixed $value the property value
* @throws UnknownPropertyException if the property is not defined
* @throws InvalidCallException if the property is read-only.
* @see __get
* @see __get
()
*/
public
function
__set
(
$name
,
$value
)
{
...
...
@@ -225,8 +227,8 @@ class Component extends Object
* @param boolean $checkVars whether to treat member variables as properties
* @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component
* @return boolean whether the property is defined
* @see canGetProperty
* @see canSetProperty
* @see canGetProperty
()
* @see canSetProperty
()
*/
public
function
hasProperty
(
$name
,
$checkVars
=
true
,
$checkBehaviors
=
true
)
{
...
...
@@ -246,7 +248,7 @@ class Component extends Object
* @param boolean $checkVars whether to treat member variables as properties
* @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component
* @return boolean whether the property can be read
* @see canSetProperty
* @see canSetProperty
()
*/
public
function
canGetProperty
(
$name
,
$checkVars
=
true
,
$checkBehaviors
=
true
)
{
...
...
@@ -276,7 +278,7 @@ class Component extends Object
* @param boolean $checkVars whether to treat member variables as properties
* @param boolean $checkBehaviors whether to treat behaviors' properties as properties of this component
* @return boolean whether the property can be written
* @see canGetProperty
* @see canGetProperty
()
*/
public
function
canSetProperty
(
$name
,
$checkVars
=
true
,
$checkBehaviors
=
true
)
{
...
...
@@ -492,7 +494,7 @@ class Component extends Object
* - an object configuration array that will be passed to [[Yii::createObject()]] to create the behavior object.
*
* @return Behavior the behavior object
* @see detachBehavior
* @see detachBehavior
()
*/
public
function
attachBehavior
(
$name
,
$behavior
)
{
...
...
@@ -505,7 +507,7 @@ class Component extends Object
* Each behavior is indexed by its name and should be a [[Behavior]] object,
* a string specifying the behavior class, or an configuration array for creating the behavior.
* @param array $behaviors list of behaviors to be attached to the component
* @see attachBehavior
* @see attachBehavior
()
*/
public
function
attachBehaviors
(
$behaviors
)
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/Controller.php
View file @
2d866186
...
...
@@ -111,7 +111,7 @@ class Controller extends Component implements ViewContextInterface
* @param array $params the parameters (name-value pairs) to be passed to the action.
* @return mixed the result of the action
* @throws InvalidRouteException if the requested action ID cannot be resolved into an action successfully.
* @see createAction
* @see createAction
()
*/
public
function
runAction
(
$id
,
$params
=
[])
{
...
...
@@ -149,8 +149,7 @@ class Controller extends Component implements ViewContextInterface
* @param string $route the route to be handled, e.g., 'view', 'comment/view', '/admin/comment/view'.
* @param array $params the parameters to be passed to the action.
* @return mixed the result of the action
* @see runAction
* @see forward
* @see runAction()
*/
public
function
run
(
$route
,
$params
=
[])
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/ErrorHandler.php
View file @
2d866186
...
...
@@ -16,6 +16,9 @@ use yii\web\HttpException;
* ErrorHandler displays these errors using appropriate views based on the
* nature of the errors and the mode the application runs at.
*
* ErrorHandler is configured as an application component in [[yii\base\Application]] by default.
* You can access that instance via `Yii::$app->errorHandler`.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Timur Ruziev <resurtm@gmail.com>
* @since 2.0
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/Formatter.php
View file @
2d866186
...
...
@@ -19,6 +19,9 @@ use yii\helpers\Html;
* The behavior of some of them may be configured via the properties of Formatter. For example,
* by configuring [[dateFormat]], one may control how [[asDate()]] formats the value into a date string.
*
* Formatter is configured as an application component in [[yii\base\Application]] by default.
* You can access that instance via `Yii::$app->formatter`.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/Model.php
View file @
2d866186
...
...
@@ -46,7 +46,8 @@ use yii\validators\Validator;
* @property ArrayIterator $iterator An iterator for traversing the items in the list. This property is
* read-only.
* @property string $scenario The scenario that this model is in. Defaults to [[DEFAULT_SCENARIO]].
* @property ArrayObject $validators All the validators declared in the model. This property is read-only.
* @property ArrayObject|\yii\validators\Validator[] $validators All the validators declared in the model.
* This property is read-only.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
...
...
@@ -144,7 +145,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* merge the parent rules with child rules using functions such as `array_merge()`.
*
* @return array validation rules
* @see scenarios
* @see scenarios
()
*/
public
function
rules
()
{
...
...
@@ -255,7 +256,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* merge the parent labels with child labels using functions such as `array_merge()`.
*
* @return array attribute labels (name => label)
* @see generateAttributeLabel
* @see generateAttributeLabel
()
*/
public
function
attributeLabels
()
{
...
...
@@ -349,7 +350,7 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* $model->validators[] = $newValidator;
* ~~~
*
* @return ArrayObject all the validators declared in the model.
* @return ArrayObject
|\yii\validators\Validator[]
all the validators declared in the model.
*/
public
function
getValidators
()
{
...
...
@@ -369,7 +370,6 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
{
$validators
=
[];
$scenario
=
$this
->
getScenario
();
/** @var $validator Validator */
foreach
(
$this
->
getValidators
()
as
$validator
)
{
if
(
$validator
->
isActive
(
$scenario
)
&&
(
$attribute
===
null
||
in_array
(
$attribute
,
$validator
->
attributes
,
true
)))
{
$validators
[]
=
$validator
;
...
...
@@ -444,8 +444,8 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* Returns the text label for the specified attribute.
* @param string $attribute the attribute name
* @return string the attribute label
* @see generateAttributeLabel
* @see attributeLabels
* @see generateAttributeLabel
()
* @see attributeLabels
()
*/
public
function
getAttributeLabel
(
$attribute
)
{
...
...
@@ -483,8 +483,8 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* ]
* ~~~
*
* @see getFirstErrors
* @see getFirstError
* @see getFirstErrors
()
* @see getFirstError
()
*/
public
function
getErrors
(
$attribute
=
null
)
{
...
...
@@ -498,8 +498,8 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
/**
* Returns the first error of every attribute in the model.
* @return array the first errors. An empty array will be returned if there is no error.
* @see getErrors
* @see getFirstError
* @see getErrors
()
* @see getFirstError
()
*/
public
function
getFirstErrors
()
{
...
...
@@ -520,8 +520,8 @@ class Model extends Component implements IteratorAggregate, ArrayAccess
* Returns the first error of the specified attribute.
* @param string $attribute attribute name.
* @return string the error message. Null is returned if no error.
* @see getErrors
* @see getFirstErrors
* @see getErrors
()
* @see getFirstErrors
()
*/
public
function
getFirstError
(
$attribute
)
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/Module.php
View file @
2d866186
...
...
@@ -578,7 +578,7 @@ abstract class Module extends Component
{
$parts
=
$this
->
createController
(
$route
);
if
(
is_array
(
$parts
))
{
/** @var
$controller C
ontroller */
/** @var
Controller $c
ontroller */
list
(
$controller
,
$actionID
)
=
$parts
;
$oldController
=
Yii
::
$app
->
controller
;
Yii
::
$app
->
controller
=
$controller
;
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/Object.php
View file @
2d866186
...
...
@@ -10,7 +10,10 @@ namespace yii\base;
use
Yii
;
/**
* Object is the base class that implements the *property* feature.
*
* @include @yii/base/Object.md
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
@@ -64,7 +67,7 @@ class Object implements Arrayable
* @return mixed the property value
* @throws UnknownPropertyException if the property is not defined
* @throws InvalidCallException if the property is write-only
* @see __set
* @see __set
()
*/
public
function
__get
(
$name
)
{
...
...
@@ -87,7 +90,7 @@ class Object implements Arrayable
* @param mixed $value the property value
* @throws UnknownPropertyException if the property is not defined
* @throws InvalidCallException if the property is read-only
* @see __get
* @see __get
()
*/
public
function
__set
(
$name
,
$value
)
{
...
...
@@ -168,8 +171,8 @@ class Object implements Arrayable
* @param string $name the property name
* @param boolean $checkVars whether to treat member variables as properties
* @return boolean whether the property is defined
* @see canGetProperty
* @see canSetProperty
* @see canGetProperty
()
* @see canSetProperty
()
*/
public
function
hasProperty
(
$name
,
$checkVars
=
true
)
{
...
...
@@ -187,7 +190,7 @@ class Object implements Arrayable
* @param string $name the property name
* @param boolean $checkVars whether to treat member variables as properties
* @return boolean whether the property can be read
* @see canSetProperty
* @see canSetProperty
()
*/
public
function
canGetProperty
(
$name
,
$checkVars
=
true
)
{
...
...
@@ -205,7 +208,7 @@ class Object implements Arrayable
* @param string $name the property name
* @param boolean $checkVars whether to treat member variables as properties
* @return boolean whether the property can be written
* @see canGetProperty
* @see canGetProperty
()
*/
public
function
canSetProperty
(
$name
,
$checkVars
=
true
)
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/Request.php
View file @
2d866186
...
...
@@ -8,6 +8,7 @@
namespace
yii\base
;
/**
* Request represents a request that is handled by an [[Application]].
*
* @property boolean $isConsoleRequest The value indicating whether the current request is made via console.
* @property string $scriptFile Entry script file path (processed w/ realpath()).
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/Response.php
View file @
2d866186
...
...
@@ -8,6 +8,8 @@
namespace
yii\base
;
/**
* Response represents the response of an [[Application]] to a [[Request]].
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/View.php
View file @
2d866186
...
...
@@ -123,7 +123,7 @@ class View extends Component
* existing [[context]] will be used.
* @return string the rendering result
* @throws InvalidParamException if the view cannot be resolved or the view file does not exist.
* @see renderFile
* @see renderFile
()
*/
public
function
render
(
$view
,
$params
=
[],
$context
=
null
)
{
...
...
@@ -410,7 +410,7 @@ class View extends Component
{
$properties
[
'id'
]
=
$id
;
$properties
[
'view'
]
=
$this
;
/** @var
$cache FragmentC
ache */
/** @var
FragmentCache $c
ache */
$cache
=
FragmentCache
::
begin
(
$properties
);
if
(
$cache
->
getCachedContent
()
!==
false
)
{
$this
->
endCache
();
...
...
This diff is collapsed.
Click to expand it.
framework/yii/base/ViewEvent.php
View file @
2d866186
...
...
@@ -8,6 +8,8 @@
namespace
yii\base
;
/**
* ViewEvent represents events triggered by the [[View]] component.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/captcha/CaptchaAsset.php
View file @
2d866186
...
...
@@ -10,6 +10,8 @@ namespace yii\captcha;
use
yii\web\AssetBundle
;
/**
* This asset bundle provides the javascript files needed for the [[Captcha]] widget.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/console/Request.php
View file @
2d866186
...
...
@@ -8,6 +8,10 @@
namespace
yii\console
;
/**
* The console Request represents the environment information for a console application.
*
* It is a wrapper for the PHP `$_SERVER` variable which holds information about the
* currently running PHP script and the command line arguments given to it.
*
* @property array $params The command line arguments. It does not include the entry script name.
*
...
...
This diff is collapsed.
Click to expand it.
framework/yii/console/Response.php
View file @
2d866186
...
...
@@ -8,6 +8,8 @@
namespace
yii\console
;
/**
* The console Response represents the result of a console application by holding the [[exitCode]].
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/console/controllers/CacheController.php
View file @
2d866186
...
...
@@ -52,7 +52,7 @@ class CacheController extends Controller
*/
public
function
actionFlush
(
$component
=
'cache'
)
{
/** @var
$cache C
ache */
/** @var
Cache $c
ache */
$cache
=
Yii
::
$app
->
getComponent
(
$component
);
if
(
!
$cache
||
!
$cache
instanceof
Cache
)
{
throw
new
Exception
(
'Application component "'
.
$component
.
'" is not defined or not a cache.'
);
...
...
This diff is collapsed.
Click to expand it.
framework/yii/db/ActiveQuery.php
View file @
2d866186
...
...
@@ -122,7 +122,7 @@ class ActiveQuery extends Query
if
(
$this
->
asArray
)
{
$model
=
$row
;
}
else
{
/** @var
$class ActiveRecord
*/
/** @var
ActiveRecord $class
*/
$class
=
$this
->
modelClass
;
$model
=
$class
::
create
(
$row
);
}
...
...
@@ -145,7 +145,7 @@ class ActiveQuery extends Query
*/
public
function
createCommand
(
$db
=
null
)
{
/** @var
$modelClass ActiveRecord
*/
/** @var
ActiveRecord $modelClass
*/
$modelClass
=
$this
->
modelClass
;
if
(
$db
===
null
)
{
$db
=
$modelClass
::
getDb
();
...
...
@@ -253,7 +253,7 @@ class ActiveQuery extends Query
$models
[
$key
]
=
$row
;
}
}
else
{
/** @var
$class ActiveRecord
*/
/** @var
ActiveRecord $class
*/
$class
=
$this
->
modelClass
;
if
(
$this
->
indexBy
===
null
)
{
foreach
(
$rows
as
$row
)
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/db/ActiveRecord.php
View file @
2d866186
...
...
@@ -372,7 +372,7 @@ class ActiveRecord extends Model
* This method is overridden so that attributes and related objects can be accessed like properties.
* @param string $name property name
* @return mixed property value
* @see getAttribute
* @see getAttribute
()
*/
public
function
__get
(
$name
)
{
...
...
@@ -576,7 +576,7 @@ class ActiveRecord extends Model
* null will be returned.
* @param string $name the attribute name
* @return mixed the attribute value. Null if the attribute is not set or does not exist.
* @see hasAttribute
* @see hasAttribute
()
*/
public
function
getAttribute
(
$name
)
{
...
...
@@ -588,7 +588,7 @@ class ActiveRecord extends Model
* @param string $name the attribute name
* @param mixed $value the attribute value.
* @throws InvalidParamException if the named attribute does not exist.
* @see hasAttribute
* @see hasAttribute
()
*/
public
function
setAttribute
(
$name
,
$value
)
{
...
...
@@ -625,7 +625,7 @@ class ActiveRecord extends Model
* @param string $name the attribute name
* @return mixed the old attribute value. Null if the attribute is not loaded before
* or does not exist.
* @see hasAttribute
* @see hasAttribute
()
*/
public
function
getOldAttribute
(
$name
)
{
...
...
@@ -637,7 +637,7 @@ class ActiveRecord extends Model
* @param string $name the attribute name
* @param mixed $value the old attribute value.
* @throws InvalidParamException if the named attribute does not exist.
* @see hasAttribute
* @see hasAttribute
()
*/
public
function
setOldAttribute
(
$name
,
$value
)
{
...
...
@@ -1030,7 +1030,7 @@ class ActiveRecord extends Model
/**
* Sets the value indicating whether the record is new.
* @param boolean $value whether the record is new and should be inserted when calling [[save()]].
* @see getIsNewRecord
* @see getIsNewRecord
()
*/
public
function
setIsNewRecord
(
$value
)
{
...
...
@@ -1321,9 +1321,9 @@ class ActiveRecord extends Model
throw
new
InvalidCallException
(
'Unable to link models: both models must NOT be newly created.'
);
}
if
(
is_array
(
$relation
->
via
))
{
/** @var
$viaRelation Active
Relation */
/** @var
ActiveRelation $via
Relation */
list
(
$viaName
,
$viaRelation
)
=
$relation
->
via
;
/** @var
$viaClass ActiveRecord
*/
/** @var
ActiveRecord $viaClass
*/
$viaClass
=
$viaRelation
->
modelClass
;
$viaTable
=
$viaClass
::
tableName
();
// unset $viaName so that it can be reloaded to reflect the change
...
...
@@ -1396,9 +1396,9 @@ class ActiveRecord extends Model
if
(
$relation
->
via
!==
null
)
{
if
(
is_array
(
$relation
->
via
))
{
/** @var
$viaRelation Active
Relation */
/** @var
ActiveRelation $via
Relation */
list
(
$viaName
,
$viaRelation
)
=
$relation
->
via
;
/** @var
$viaClass ActiveRecord
*/
/** @var
ActiveRecord $viaClass
*/
$viaClass
=
$viaRelation
->
modelClass
;
$viaTable
=
$viaClass
::
tableName
();
unset
(
$this
->
_related
[
$viaName
]);
...
...
@@ -1444,7 +1444,7 @@ class ActiveRecord extends Model
if
(
!
$relation
->
multiple
)
{
unset
(
$this
->
_related
[
$name
]);
}
elseif
(
isset
(
$this
->
_related
[
$name
]))
{
/** @var
$b ActiveRecord
*/
/** @var
ActiveRecord $b
*/
foreach
(
$this
->
_related
[
$name
]
as
$a
=>
$b
)
{
if
(
$model
->
getPrimaryKey
()
==
$b
->
getPrimaryKey
())
{
unset
(
$this
->
_related
[
$name
][
$a
]);
...
...
This diff is collapsed.
Click to expand it.
framework/yii/db/ActiveRelation.php
View file @
2d866186
...
...
@@ -55,9 +55,11 @@ class ActiveRelation extends ActiveQuery
*/
public
function
__clone
()
{
// make a clone of "via" object so that the same query object can be reused multiple times
if
(
is_object
(
$this
->
via
))
{
// make a clone of "via" object so that the same query object can be reused multiple times
$this
->
via
=
clone
$this
->
via
;
}
elseif
(
is_array
(
$this
->
via
))
{
$this
->
via
=
[
$this
->
via
[
0
],
clone
$this
->
via
[
1
]];
}
}
...
...
@@ -120,7 +122,7 @@ class ActiveRelation extends ActiveQuery
$this
->
filterByModels
(
$viaModels
);
}
elseif
(
is_array
(
$this
->
via
))
{
// via relation
/** @var
$viaQuery ActiveRelation
*/
/** @var
ActiveRelation $viaQuery
*/
list
(
$viaName
,
$viaQuery
)
=
$this
->
via
;
if
(
$viaQuery
->
multiple
)
{
$viaModels
=
$viaQuery
->
all
();
...
...
@@ -154,13 +156,13 @@ class ActiveRelation extends ActiveQuery
if
(
$this
->
via
instanceof
self
)
{
// via pivot table
/** @var
$viaQuery ActiveRelation
*/
/** @var
ActiveRelation $viaQuery
*/
$viaQuery
=
$this
->
via
;
$viaModels
=
$viaQuery
->
findPivotRows
(
$primaryModels
);
$this
->
filterByModels
(
$viaModels
);
}
elseif
(
is_array
(
$this
->
via
))
{
// via relation
/** @var
$viaQuery ActiveRelation
*/
/** @var
ActiveRelation $viaQuery
*/
list
(
$viaName
,
$viaQuery
)
=
$this
->
via
;
$viaQuery
->
primaryModel
=
null
;
$viaModels
=
$viaQuery
->
findWith
(
$viaName
,
$primaryModels
);
...
...
@@ -306,7 +308,7 @@ class ActiveRelation extends ActiveQuery
return
[];
}
$this
->
filterByModels
(
$primaryModels
);
/** @var
$primaryModel ActiveRecord
*/
/** @var
ActiveRecord $primaryModel
*/
$primaryModel
=
reset
(
$primaryModels
);
$db
=
$primaryModel
->
getDb
();
list
(
$sql
,
$params
)
=
$db
->
getQueryBuilder
()
->
build
(
$this
);
...
...
This diff is collapsed.
Click to expand it.
framework/yii/db/Command.php
View file @
2d866186
...
...
@@ -366,7 +366,7 @@ class Command extends \yii\base\Component
Yii
::
info
(
$rawSql
,
__METHOD__
);
/** @var
$cache \yii\caching\C
ache */
/** @var
\yii\caching\Cache $c
ache */
if
(
$db
->
enableQueryCache
&&
$method
!==
''
)
{
$cache
=
is_string
(
$db
->
queryCache
)
?
Yii
::
$app
->
getComponent
(
$db
->
queryCache
)
:
$db
->
queryCache
;
}
...
...
This diff is collapsed.
Click to expand it.
framework/yii/db/Query.php
View file @
2d866186
...
...
@@ -39,12 +39,12 @@ class Query extends Component
{
/**
* Sort ascending
* @see orderBy
* @see orderBy
()
*/
const
SORT_ASC
=
false
;
/**
* Sort descending
* @see orderBy
* @see orderBy
()
*/
const
SORT_DESC
=
true
;
...
...
This diff is collapsed.
Click to expand it.
framework/yii/db/Schema.php
View file @
2d866186
...
...
@@ -92,7 +92,7 @@ abstract class Schema extends Object
$realName
=
$this
->
getRawTableName
(
$name
);
if
(
$db
->
enableSchemaCache
&&
!
in_array
(
$name
,
$db
->
schemaCacheExclude
,
true
))
{
/** @var
$cache C
ache */
/** @var
Cache $c
ache */
$cache
=
is_string
(
$db
->
schemaCache
)
?
Yii
::
$app
->
getComponent
(
$db
->
schemaCache
)
:
$db
->
schemaCache
;
if
(
$cache
instanceof
Cache
)
{
$key
=
$this
->
getCacheKey
(
$name
);
...
...
@@ -215,7 +215,7 @@ abstract class Schema extends Object
*/
public
function
refresh
()
{
/** @var
$cache C
ache */
/** @var
Cache $c
ache */
$cache
=
is_string
(
$this
->
db
->
schemaCache
)
?
Yii
::
$app
->
getComponent
(
$this
->
db
->
schemaCache
)
:
$this
->
db
->
schemaCache
;
if
(
$this
->
db
->
enableSchemaCache
&&
$cache
instanceof
Cache
)
{
GroupDependency
::
invalidate
(
$cache
,
$this
->
getCacheGroup
());
...
...
@@ -291,7 +291,7 @@ abstract class Schema extends Object
* then this method will do nothing.
* @param string $name table name
* @return string the properly quoted table name
* @see quoteSimpleTableName
* @see quoteSimpleTableName
()
*/
public
function
quoteTableName
(
$name
)
{
...
...
@@ -316,7 +316,7 @@ abstract class Schema extends Object
* then this method will do nothing.
* @param string $name column name
* @return string the properly quoted column name
* @see quoteSimpleColumnName
* @see quoteSimpleColumnName
()
*/
public
function
quoteColumnName
(
$name
)
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/grid/ActionColumn.php
View file @
2d866186
...
...
@@ -12,6 +12,8 @@ use Closure;
use
yii\helpers\Html
;
/**
* ActionColumn is a column for the [[GridView]] widget that displays buttons for viewing and manipulating the items.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/grid/DataColumn.php
View file @
2d866186
...
...
@@ -15,6 +15,10 @@ use yii\helpers\Html;
use
yii\helpers\Inflector
;
/**
* DataColumn is the default column type for the [[GridView]] widget.
*
* It is used to show data columns and allows sorting them.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/grid/GridView.php
View file @
2d866186
...
...
@@ -16,6 +16,10 @@ use yii\helpers\Json;
use
yii\widgets\BaseListView
;
/**
* The GridView widget is used to display data in a grid.
*
* It provides features like sorting, paging and also filtering the data.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/grid/GridViewAsset.php
View file @
2d866186
...
...
@@ -10,6 +10,7 @@ namespace yii\grid;
use
yii\web\AssetBundle
;
/**
* This asset bundle provides the javascript files for the [[GridView]] widget.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
...
...
This diff is collapsed.
Click to expand it.
framework/yii/helpers/BaseHtml.php
View file @
2d866186
...
...
@@ -86,7 +86,7 @@ class BaseHtml
* @param boolean $doubleEncode whether to encode HTML entities in `$content`. If false,
* HTML entities in `$content` will not be further encoded.
* @return string the encoded content
* @see decode
* @see decode
()
* @see http://www.php.net/manual/en/function.htmlspecialchars.php
*/
public
static
function
encode
(
$content
,
$doubleEncode
=
true
)
...
...
@@ -99,7 +99,7 @@ class BaseHtml
* This is the opposite of [[encode()]].
* @param string $content the content to be decoded
* @return string the decoded content
* @see encode
* @see encode
()
* @see http://www.php.net/manual/en/function.htmlspecialchars-decode.php
*/
public
static
function
decode
(
$content
)
...
...
@@ -116,8 +116,8 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
* @return string the generated HTML tag
* @see beginTag
* @see endTag
* @see beginTag
()
* @see endTag
()
*/
public
static
function
tag
(
$name
,
$content
=
''
,
$options
=
[])
{
...
...
@@ -132,8 +132,8 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
* @return string the generated start tag
* @see endTag
* @see tag
* @see endTag
()
* @see tag
()
*/
public
static
function
beginTag
(
$name
,
$options
=
[])
{
...
...
@@ -144,8 +144,8 @@ class BaseHtml
* Generates an end tag.
* @param string $name the tag name
* @return string the generated end tag
* @see beginTag
* @see tag
* @see beginTag
()
* @see tag
()
*/
public
static
function
endTag
(
$name
)
{
...
...
@@ -187,7 +187,7 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
* @return string the generated link tag
* @see url
* @see url
()
*/
public
static
function
cssFile
(
$url
,
$options
=
[])
{
...
...
@@ -203,7 +203,7 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
* @return string the generated script tag
* @see url
* @see url
()
*/
public
static
function
jsFile
(
$url
,
$options
=
[])
{
...
...
@@ -222,7 +222,7 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
* @return string the generated form start tag.
* @see endForm
* @see endForm
()
*/
public
static
function
beginForm
(
$action
=
''
,
$method
=
'post'
,
$options
=
[])
{
...
...
@@ -271,7 +271,7 @@ class BaseHtml
/**
* Generates a form end tag.
* @return string the generated tag
* @see beginForm
* @see beginForm
()
*/
public
static
function
endForm
()
{
...
...
@@ -290,7 +290,7 @@ class BaseHtml
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
* @return string the generated hyperlink
* @see url
* @see url
()
*/
public
static
function
a
(
$text
,
$url
=
null
,
$options
=
[])
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/helpers/BaseInflector.php
View file @
2d866186
...
...
@@ -328,7 +328,7 @@ class BaseInflector
* Converts a word like "send_email" to "SendEmail". It
* will remove non alphanumeric character from the word, so
* "who's online" will be converted to "WhoSOnline"
* @see variablize
* @see variablize
()
* @param string $word the word to CamelCase
* @return string
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/i18n/Formatter.php
View file @
2d866186
...
...
@@ -19,6 +19,15 @@ use yii\base\InvalidConfigException;
* Formatter requires the PHP "intl" extension to be installed. Formatter supports localized
* formatting of date, time and numbers, based on the current [[locale]].
*
* This Formatter can replace the `formatter` application component that is configured by default.
* To do so, add the following to your application config under `components`:
*
* ```php
* 'formatter' => [
* 'class' => 'yii\i18n\Formatter',
* ]
* ```
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/i18n/I18N.php
View file @
2d866186
...
...
@@ -14,6 +14,9 @@ use yii\base\InvalidConfigException;
/**
* I18N provides features related with internationalization (I18N) and localization (L10N).
*
* I18N is configured as an application component in [[yii\base\Application]] by default.
* You can access that instance via `Yii::$app->i18n`.
*
* @property MessageFormatter $messageFormatter The message formatter to be used to format message via ICU
* message format. Note that the type of this property differs in getter and setter. See
* [[getMessageFormatter()]] and [[setMessageFormatter()]] for details.
...
...
This diff is collapsed.
Click to expand it.
framework/yii/log/Target.php
View file @
2d866186
...
...
@@ -112,7 +112,7 @@ abstract class Target extends Component
{
$context
=
[];
if
(
$this
->
logUser
&&
(
$user
=
Yii
::
$app
->
getComponent
(
'user'
,
false
))
!==
null
)
{
/** @var
$user \yii\web\U
ser */
/** @var
\yii\web\User $u
ser */
$context
[]
=
'User: '
.
$user
->
getId
();
}
...
...
This diff is collapsed.
Click to expand it.
framework/yii/mail/BaseMailer.php
View file @
2d866186
...
...
@@ -281,7 +281,7 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont
$file
=
$path
.
'/'
.
call_user_func
(
$this
->
fileTransportCallback
,
$this
,
$message
);
}
else
{
$time
=
microtime
(
true
);
$file
=
$path
.
'/'
.
date
(
'Ymd-His-'
,
$time
)
.
sprintf
(
'%04d'
,
(
int
)((
$time
-
(
int
)
$time
)
*
10000
))
.
'-'
.
sprintf
(
'%04d'
,
mt_rand
(
0
,
10000
))
.
'.
txt
'
;
$file
=
$path
.
'/'
.
date
(
'Ymd-His-'
,
$time
)
.
sprintf
(
'%04d'
,
(
int
)((
$time
-
(
int
)
$time
)
*
10000
))
.
'-'
.
sprintf
(
'%04d'
,
mt_rand
(
0
,
10000
))
.
'.
eml
'
;
}
file_put_contents
(
$file
,
$message
->
toString
());
return
true
;
...
...
This diff is collapsed.
Click to expand it.
framework/yii/rbac/PhpManager.php
View file @
2d866186
...
...
@@ -36,8 +36,8 @@ class PhpManager extends Manager
* If not set, it will be using 'protected/data/rbac.php' as the data file.
* Make sure this file is writable by the Web server process if the authorization
* needs to be changed.
* @see loadFromFile
* @see saveToFile
* @see loadFromFile
()
* @see saveToFile
()
*/
public
$authFile
;
...
...
@@ -74,7 +74,7 @@ class PhpManager extends Manager
if
(
!
isset
(
$this
->
_items
[
$itemName
]))
{
return
false
;
}
/** @var
$item I
tem */
/** @var
Item $i
tem */
$item
=
$this
->
_items
[
$itemName
];
Yii
::
trace
(
'Checking permission: '
.
$item
->
getName
(),
__METHOD__
);
if
(
!
isset
(
$params
[
'userId'
]))
{
...
...
@@ -85,7 +85,7 @@ class PhpManager extends Manager
return
true
;
}
if
(
isset
(
$this
->
_assignments
[
$userId
][
$itemName
]))
{
/** @var
$assignment A
ssignment */
/** @var
Assignment $a
ssignment */
$assignment
=
$this
->
_assignments
[
$userId
][
$itemName
];
if
(
$this
->
executeBizRule
(
$assignment
->
bizRule
,
$params
,
$assignment
->
data
))
{
return
true
;
...
...
@@ -113,9 +113,9 @@ class PhpManager extends Manager
if
(
!
isset
(
$this
->
_items
[
$childName
],
$this
->
_items
[
$itemName
]))
{
throw
new
Exception
(
"Either '
$itemName
' or '
$childName
' does not exist."
);
}
/** @var
$child Item
*/
/** @var
Item $child
*/
$child
=
$this
->
_items
[
$childName
];
/** @var
$item I
tem */
/** @var
Item $i
tem */
$item
=
$this
->
_items
[
$itemName
];
$this
->
checkItemChildType
(
$item
->
type
,
$child
->
type
);
if
(
$this
->
detectLoop
(
$itemName
,
$childName
))
{
...
...
@@ -270,14 +270,14 @@ class PhpManager extends Manager
$items
=
[];
if
(
$userId
===
null
)
{
foreach
(
$this
->
_items
as
$name
=>
$item
)
{
/** @var
$item I
tem */
/** @var
Item $i
tem */
if
(
$item
->
type
==
$type
)
{
$items
[
$name
]
=
$item
;
}
}
}
elseif
(
isset
(
$this
->
_assignments
[
$userId
]))
{
foreach
(
$this
->
_assignments
[
$userId
]
as
$assignment
)
{
/** @var
$assignment A
ssignment */
/** @var
Assignment $a
ssignment */
$name
=
$assignment
->
itemName
;
if
(
isset
(
$this
->
_items
[
$name
])
&&
(
$type
===
null
||
$this
->
_items
[
$name
]
->
type
==
$type
))
{
$items
[
$name
]
=
$this
->
_items
[
$name
];
...
...
@@ -400,7 +400,7 @@ class PhpManager extends Manager
{
$items
=
[];
foreach
(
$this
->
_items
as
$name
=>
$item
)
{
/** @var
$item I
tem */
/** @var
Item $i
tem */
$items
[
$name
]
=
[
'type'
=>
$item
->
type
,
'description'
=>
$item
->
description
,
...
...
@@ -409,7 +409,7 @@ class PhpManager extends Manager
];
if
(
isset
(
$this
->
_children
[
$name
]))
{
foreach
(
$this
->
_children
[
$name
]
as
$child
)
{
/** @var
$child Item
*/
/** @var
Item $child
*/
$items
[
$name
][
'children'
][]
=
$child
->
getName
();
}
}
...
...
@@ -417,7 +417,7 @@ class PhpManager extends Manager
foreach
(
$this
->
_assignments
as
$userId
=>
$assignments
)
{
foreach
(
$assignments
as
$name
=>
$assignment
)
{
/** @var
$assignment A
ssignment */
/** @var
Assignment $a
ssignment */
if
(
isset
(
$items
[
$name
]))
{
$items
[
$name
][
'assignments'
][
$userId
]
=
[
'bizRule'
=>
$assignment
->
bizRule
,
...
...
@@ -505,7 +505,7 @@ class PhpManager extends Manager
return
false
;
}
foreach
(
$this
->
_children
[
$childName
]
as
$child
)
{
/** @var
$child Item
*/
/** @var
Item $child
*/
if
(
$this
->
detectLoop
(
$itemName
,
$child
->
getName
()))
{
return
true
;
}
...
...
@@ -517,7 +517,7 @@ class PhpManager extends Manager
* Loads the authorization data from a PHP script file.
* @param string $file the file path.
* @return array the authorization data
* @see saveToFile
* @see saveToFile
()
*/
protected
function
loadFromFile
(
$file
)
{
...
...
@@ -532,7 +532,7 @@ class PhpManager extends Manager
* Saves the authorization data to a PHP script file.
* @param array $data the authorization data
* @param string $file the file path.
* @see loadFromFile
* @see loadFromFile
()
*/
protected
function
saveToFile
(
$data
,
$file
)
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/requirements/requirements.php
View file @
2d866186
...
...
@@ -3,7 +3,7 @@
* These are the Yii core requirements for the [[YiiRequirementChecker]] instance.
* These requirements are mandatory for any Yii application.
*
* @var
$this YiiRequirementChecker
* @var
YiiRequirementChecker $this
*/
return
array
(
array
(
...
...
This diff is collapsed.
Click to expand it.
framework/yii/requirements/views/console/index.php
View file @
2d866186
<?php
/* @var
$this YiiRequirementChecker
*/
/* @var
$summary arra
y */
/* @var
$requirements array[]
*/
/* @var
YiiRequirementChecker $this
*/
/* @var
array $summar
y */
/* @var
array[] $requirements
*/
echo
"
\n
Yii Application Requirement Checker
\n\n
"
;
...
...
This diff is collapsed.
Click to expand it.
framework/yii/requirements/views/web/index.php
View file @
2d866186
<?php
/* @var
$this YiiRequirementChecker
*/
/* @var
$summary arra
y */
/* @var
$requirements array[]
*/
/* @var
YiiRequirementChecker $this
*/
/* @var
array $summar
y */
/* @var
array[] $requirements
*/
?>
<!DOCTYPE html>
<html
lang=
"en"
>
...
...
This diff is collapsed.
Click to expand it.
framework/yii/validators/ExistValidator.php
View file @
2d866186
...
...
@@ -65,7 +65,7 @@ class ExistValidator extends Validator
return
;
}
/** @var
$className \yii\db\ActiveRecord
*/
/** @var
\yii\db\ActiveRecord $className
*/
$className
=
$this
->
className
===
null
?
get_class
(
$object
)
:
$this
->
className
;
$attributeName
=
$this
->
attributeName
===
null
?
$attribute
:
$this
->
attributeName
;
$query
=
$className
::
find
();
...
...
@@ -92,7 +92,7 @@ class ExistValidator extends Validator
if
(
$this
->
attributeName
===
null
)
{
throw
new
InvalidConfigException
(
'The "attributeName" property must be set.'
);
}
/** @var
$className \yii\db\ActiveRecord
*/
/** @var
\yii\db\ActiveRecord $className
*/
$className
=
$this
->
className
;
$query
=
$className
::
find
();
$query
->
where
([
$this
->
attributeName
=>
$value
]);
...
...
This diff is collapsed.
Click to expand it.
framework/yii/validators/PunycodeAsset.php
View file @
2d866186
...
...
@@ -9,6 +9,8 @@ namespace yii\validators;
use
yii\web\AssetBundle
;
/**
* This asset bundle provides the javascript files needed for the [[EmailValidator]]s client validation.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/validators/UniqueValidator.php
View file @
2d866186
...
...
@@ -60,7 +60,7 @@ class UniqueValidator extends Validator
return
;
}
/** @var
$className \yii\db\ActiveRecord
*/
/** @var
\yii\db\ActiveRecord $className
*/
$className
=
$this
->
className
===
null
?
get_class
(
$object
)
:
$this
->
className
;
$attributeName
=
$this
->
attributeName
===
null
?
$attribute
:
$this
->
attributeName
;
...
...
This diff is collapsed.
Click to expand it.
framework/yii/validators/ValidationAsset.php
View file @
2d866186
...
...
@@ -9,6 +9,8 @@ namespace yii\validators;
use
yii\web\AssetBundle
;
/**
* This asset bundle provides the javascript files for client validation.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/AccessControl.php
View file @
2d866186
...
...
@@ -102,7 +102,7 @@ class AccessControl extends ActionFilter
{
$user
=
Yii
::
$app
->
getUser
();
$request
=
Yii
::
$app
->
getRequest
();
/** @var
$rule AccessR
ule */
/** @var
AccessRule $r
ule */
foreach
(
$this
->
rules
as
$rule
)
{
if
(
$allow
=
$rule
->
allows
(
$action
,
$user
,
$request
))
{
return
true
;
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/AssetConverter.php
View file @
2d866186
...
...
@@ -14,6 +14,8 @@ use yii\base\Exception;
/**
* AssetConverter supports conversion of several popular script formats into JS or CSS scripts.
*
* It is used by [[AssetManager]] to convert files after they have been published.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
@@ -63,6 +65,8 @@ class AssetConverter extends Component implements AssetConverterInterface
* @param string $asset the name of the asset file
* @param string $result the name of the file to be generated by the converter command
* @return bool true on success, false on failure. Failures will be logged.
* @throws \yii\base\Exception when the command fails and YII_DEBUG is true.
* In production mode the error will be logged.
*/
protected
function
runCommand
(
$command
,
$basePath
,
$asset
,
$result
)
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/AssetManager.php
View file @
2d866186
...
...
@@ -16,6 +16,22 @@ use yii\helpers\FileHelper;
/**
* AssetManager manages asset bundles and asset publishing.
*
* AssetManager is configured as an application component in [[yii\web\Application]] by default.
* You can access that instance via `Yii::$app->assetManager`.
*
* You can modify its configuration by adding an array to your application config under `components`
* as it is shown in the following example:
*
* ~~~
* 'assetManager' => [
* 'bundles' => [
* // you can override AssetBundle configs here
* ],
* //'linkAssets' => true,
* // ...
* ]
* ~~~
*
* @property AssetConverterInterface $converter The asset converter. Note that the type of this property
* differs in getter and setter. See [[getConverter()]] and [[setConverter()]] for details.
*
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/CacheSession.php
View file @
2d866186
...
...
@@ -19,7 +19,17 @@ use yii\base\InvalidConfigException;
*
* Beware, by definition cache storage are volatile, which means the data stored on them
* may be swapped out and get lost. Therefore, you must make sure the cache used by this component
* is NOT volatile. If you want to use database as storage medium, use [[DbSession]] is a better choice.
* is NOT volatile. If you want to use database as storage medium, [[DbSession]] is a better choice.
*
* The following example shows how you can configure the application to use CacheSession:
* Add the following to your application config under `components`:
*
* ~~~
* 'session' => [
* 'class' => 'yii\web\CacheSession',
* // 'cache' => 'mycache',
* ]
* ~~~
*
* @property boolean $useCustomStorage Whether to use custom storage. This property is read-only.
*
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/Controller.php
View file @
2d866186
...
...
@@ -150,6 +150,13 @@ class Controller extends \yii\base\Controller
* Redirects the browser to the specified URL.
* This method is a shortcut to [[Response::redirect()]].
*
* You can use it in an action by returning the [[Response]] directly:
*
* ```php
* // stop executing this action and redirect to login page
* return $this->redirect(['login']);
* ```
*
* @param string|array $url the URL to be redirected to. This can be in one of the following formats:
*
* - a string representing a URL (e.g. "http://example.com")
...
...
@@ -172,6 +179,14 @@ class Controller extends \yii\base\Controller
/**
* Redirects the browser to the home page.
*
* You can use this method in an action by returning the [[Response]] directly:
*
* ```php
* // stop executing this action and redirect to home page
* return $this->goHome();
* ```
*
* @return Response the current response object
*/
public
function
goHome
()
...
...
@@ -181,6 +196,14 @@ class Controller extends \yii\base\Controller
/**
* Redirects the browser to the last visited page.
*
* You can use this method in an action by returning the [[Response]] directly:
*
* ```php
* // stop executing this action and redirect to last visited page
* return $this->goBack();
* ```
*
* @param string|array $defaultUrl the default return URL in case it was not set previously.
* If this is null and the return URL was not set previously, [[Application::homeUrl]] will be redirected to.
* Please refer to [[User::setReturnUrl()]] on accepted format of the URL.
...
...
@@ -195,6 +218,14 @@ class Controller extends \yii\base\Controller
/**
* Refreshes the current page.
* This method is a shortcut to [[Response::refresh()]].
*
* You can use it in an action by returning the [[Response]] directly:
*
* ```php
* // stop executing this action and refresh the current page
* return $this->refresh();
* ```
*
* @param string $anchor the anchor that should be appended to the redirection URL.
* Defaults to empty. Make sure the anchor starts with '#' if you want to specify it.
* @return Response the response object itself
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/DbSession.php
View file @
2d866186
...
...
@@ -19,6 +19,7 @@ use yii\base\InvalidConfigException;
* must be pre-created. The table name can be changed by setting [[sessionTable]].
*
* The following example shows how you can configure the application to use DbSession:
* Add the following to your application config under `components`:
*
* ~~~
* 'session' => [
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/HttpCache.php
View file @
2d866186
...
...
@@ -12,7 +12,32 @@ use yii\base\ActionFilter;
use
yii\base\Action
;
/**
* The HttpCache provides functionality for caching via HTTP Last-Modified and Etag headers
* The HttpCache provides functionality for caching via HTTP Last-Modified and Etag headers.
*
* It is an action filter that can be added to a controller and handles the `beforeAction` event.
*
* To use AccessControl, declare it in the `behaviors()` method of your controller class.
* In the following example the filter will be applied to the `list`-action and
* the Last-Modified header will contain the date of the last update to the user table in the database.
*
* ~~~
* public function behaviors()
* {
* return [
* 'httpCache' => [
* 'class' => \yii\web\HttpCache::className(),
* 'only' => ['list'],
* 'lastModified' => function ($action, $params) {
* $q = new Query();
* return strtotime($q->from('users')->max('updated_timestamp'));
* },
* // 'etagSeed' => function ($action, $params) {
* // return // generate etag seed here
* // }
* ],
* ];
* }
* ~~~
*
* @author Da:Sourcerer <webmaster@dasourcerer.net>
* @author Qiang Xue <qiang.xue@gmail.com>
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/HttpException.php
View file @
2d866186
...
...
@@ -16,6 +16,14 @@ use yii\base\UserException;
* keeps a standard HTTP status code (e.g. 404, 500). Error handlers may use this status code
* to decide how to format the error page.
*
* Throwing an HttpException like in the following example will result in the 404 page to be displayed.
*
* ```php
* if ($item === null) { // item does not exist
* throw new \yii\web\HttpException(404, 'The requested Item could not be found.');
* }
* ```
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/PageCache.php
View file @
2d866186
...
...
@@ -15,6 +15,35 @@ use yii\caching\Dependency;
/**
* The PageCache provides functionality for whole page caching
*
* It is an action filter that can be added to a controller and handles the `beforeAction` event.
*
* To use PageCache, declare it in the `behaviors()` method of your controller class.
* In the following example the filter will be applied to the `list`-action and
* cache the whole page for maximum 60 seconds or until the count of entries in the post table changes.
* It also stores different versions of the page depended on the route ([[varyByRoute]] is true by default),
* the application language and user id.
*
* ~~~
* public function behaviors()
* {
* return [
* 'pageCache' => [
* 'class' => \yii\web\PageCache::className(),
* 'only' => ['list'],
* 'duration' => 60,
* 'dependecy' => [
* 'class' => 'yii\caching\DbDependency',
* 'sql' => 'SELECT COUNT(*) FROM post',
* ],
* 'variations' => [
* Yii::$app->language,
* Yii::$app->user->id
* ]
* ],
* ];
* }
* ~~~
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
@@ -60,6 +89,7 @@ class PageCache extends ActionFilter
* [
* Yii::$app->language,
* ]
* ~~~
*/
public
$variations
;
/**
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/Request.php
View file @
2d866186
...
...
@@ -18,6 +18,9 @@ use yii\helpers\Security;
* Also it provides an interface to retrieve request parameters from $_POST, $_GET, $_COOKIES and REST
* parameters sent via other HTTP methods like PUT or DELETE.
*
* Request is configured as an application component in [[yii\web\Application]] by default.
* You can access that instance via `Yii::$app->request`.
*
* @property string $absoluteUrl The currently requested absolute URL. This property is read-only.
* @property string $acceptTypes User browser accept types, null if not present. This property is read-only.
* @property array $acceptedContentTypes The content types ordered by the preference level. The first element
...
...
@@ -116,8 +119,8 @@ class Request extends \yii\base\Request
/**
* @var string|boolean the name of the POST parameter that is used to indicate if a request is a PUT, PATCH or DELETE
* request tunneled through POST. Default to '_method'.
* @see getMethod
* @see getRestParams
* @see getMethod
()
* @see getRestParams
()
*/
public
$restVar
=
'_method'
;
...
...
@@ -242,7 +245,7 @@ class Request extends \yii\base\Request
/**
* Returns the request parameters for the RESTful request.
* @return array the RESTful request parameters
* @see getMethod
* @see getMethod
()
*/
public
function
getRestParams
()
{
...
...
@@ -298,7 +301,7 @@ class Request extends \yii\base\Request
* @param string $name the GET parameter name. If not specified, whole $_GET is returned.
* @param mixed $defaultValue the default parameter value if the GET parameter does not exist.
* @return mixed the GET parameter value
* @see getPost
* @see getPost
()
*/
public
function
get
(
$name
=
null
,
$defaultValue
=
null
)
{
...
...
@@ -324,7 +327,7 @@ class Request extends \yii\base\Request
* @param mixed $defaultValue the default parameter value if the POST parameter does not exist.
* @property array the POST request parameter values
* @return mixed the POST parameter value
* @see get
* @see get
()
*/
public
function
getPost
(
$name
=
null
,
$defaultValue
=
null
)
{
...
...
@@ -387,7 +390,7 @@ class Request extends \yii\base\Request
* By default this is determined based on the user request information.
* You may explicitly specify it by setting the [[setHostInfo()|hostInfo]] property.
* @return string schema and hostname part (with port number if needed) of the request URL (e.g. `http://www.yiiframework.com`)
* @see setHostInfo
* @see setHostInfo
()
*/
public
function
getHostInfo
()
{
...
...
@@ -426,7 +429,7 @@ class Request extends \yii\base\Request
* This is similar to [[scriptUrl]] except that it does not include the script file name,
* and the ending slashes are removed.
* @return string the relative URL for the application
* @see setScriptUrl
* @see setScriptUrl
()
*/
public
function
getBaseUrl
()
{
...
...
@@ -743,7 +746,7 @@ class Request extends \yii\base\Request
* Defaults to 80, or the port specified by the server if the current
* request is insecure.
* @return integer port number for insecure requests.
* @see setPort
* @see setPort
()
*/
public
function
getPort
()
{
...
...
@@ -774,7 +777,7 @@ class Request extends \yii\base\Request
* Defaults to 443, or the port specified by the server if the current
* request is secure.
* @return integer port number for secure requests.
* @see setSecurePort
* @see setSecurePort
()
*/
public
function
getSecurePort
()
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/Response.php
View file @
2d866186
...
...
@@ -22,6 +22,20 @@ use yii\helpers\StringHelper;
* It holds the [[headers]], [[cookies]] and [[content]] that is to be sent to the client.
* It also controls the HTTP [[statusCode|status code]].
*
* Response is configured as an application component in [[yii\web\Application]] by default.
* You can access that instance via `Yii::$app->response`.
*
* You can modify its configuration by adding an array to your application config under `components`
* as it is shown in the following example:
*
* ~~~
* 'response' => [
* 'format' => yii\web\Response::FORMAT_JSON,
* 'charset' => 'UTF-8',
* // ...
* ]
* ~~~
*
* @property CookieCollection $cookies The cookie collection. This property is read-only.
* @property HeaderCollection $headers The header collection. This property is read-only.
* @property boolean $isClientError Whether this response indicates a client error. This property is
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/Session.php
View file @
2d866186
...
...
@@ -15,7 +15,7 @@ use yii\base\InvalidParamException;
* Session provides session data management and the related configurations.
*
* Session is a Web application component that can be accessed via `Yii::$app->session`.
*
* To start the session, call [[open()]]; To complete and send out session data, call [[close()]];
* To destroy the session, call [[destroy()]].
*
...
...
@@ -82,6 +82,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
public
$flashVar
=
'__flash'
;
/**
* @var array parameter-value pairs to override default session cookie parameters that are used for session_set_cookie_params() function
* Array may have the following possible keys: 'lifetime', 'path', 'domain', 'secure', 'httpOnly'
* @see http://www.php.net/manual/en/function.session-set-cookie-params.php
*/
private
$_cookieParams
=
[
'httpOnly'
=>
true
];
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/UploadedFile.php
View file @
2d866186
...
...
@@ -74,7 +74,7 @@ class UploadedFile extends Object
* For example, '[1]file' for tabular file uploading; and 'file[1]' for an element in a file array.
* @return UploadedFile the instance of the uploaded file.
* Null is returned if no file is uploaded for the specified model attribute.
* @see getInstanceByName
* @see getInstanceByName
()
*/
public
static
function
getInstance
(
$model
,
$attribute
)
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/UrlManager.php
View file @
2d866186
...
...
@@ -14,6 +14,22 @@ use yii\caching\Cache;
/**
* UrlManager handles HTTP request parsing and creation of URLs based on a set of rules.
*
* UrlManager is configured as an application component in [[yii\base\Application]] by default.
* You can access that instance via `Yii::$app->urlManager`.
*
* You can modify its configuration by adding an array to your application config under `components`
* as it is shown in the following example:
*
* ~~~
* 'urlManager' => [
* 'enablePrettyUrl' => true,
* 'rules' => [
* // your rules go here
* ],
* // ...
* ]
* ~~~
*
* @property string $baseUrl The base URL that is used by [[createUrl()]] to prepend URLs it creates.
* @property string $hostInfo The host info (e.g. "http://www.example.com") that is used by
* [[createAbsoluteUrl()]] to prepend URLs it creates.
...
...
@@ -169,7 +185,7 @@ class UrlManager extends Component
{
if
(
$this
->
enablePrettyUrl
)
{
$pathInfo
=
$request
->
getPathInfo
();
/** @var
$rule UrlR
ule */
/** @var
UrlRule $r
ule */
foreach
(
$this
->
rules
as
$rule
)
{
if
((
$result
=
$rule
->
parseRequest
(
$this
,
$request
))
!==
false
)
{
Yii
::
trace
(
"Request parsed with URL rule:
{
$rule
->
name
}
"
,
__METHOD__
);
...
...
@@ -224,7 +240,7 @@ class UrlManager extends Component
$baseUrl
=
$this
->
getBaseUrl
();
if
(
$this
->
enablePrettyUrl
)
{
/** @var
$rule UrlR
ule */
/** @var
UrlRule $r
ule */
foreach
(
$this
->
rules
as
$rule
)
{
if
((
$url
=
$rule
->
createUrl
(
$this
,
$route
,
$params
))
!==
false
)
{
if
(
$rule
->
host
!==
null
)
{
...
...
@@ -282,7 +298,7 @@ class UrlManager extends Component
public
function
getBaseUrl
()
{
if
(
$this
->
_baseUrl
===
null
)
{
/** @var
$request \yii\web\R
equest */
/** @var
\yii\web\Request $r
equest */
$request
=
Yii
::
$app
->
getRequest
();
$this
->
_baseUrl
=
$this
->
showScriptName
||
!
$this
->
enablePrettyUrl
?
$request
->
getScriptUrl
()
:
$request
->
getBaseUrl
();
}
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/UrlRule.php
View file @
2d866186
...
...
@@ -11,7 +11,17 @@ use yii\base\Object;
use
yii\base\InvalidConfigException
;
/**
* UrlRule represents a rule used for parsing and generating URLs.
* UrlRule represents a rule used by [[UrlManager]] for parsing and generating URLs.
*
* To define your own URL parsing and creation logic you can extend from this class
* and add it to [[UrlManager::rules]] like this:
*
* ~~~
* 'rules' => [
* ['class' => 'MyUrlRule', 'pattern' => '...', 'route' => 'site/index', ...],
* // ...
* ]
* ~~~
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/User.php
View file @
2d866186
...
...
@@ -20,6 +20,21 @@ use yii\base\InvalidConfigException;
* User works with a class implementing the [[IdentityInterface]]. This class implements
* the actual user authentication logic and is often backed by a user database table.
*
* User is configured as an application component in [[yii\web\Application]] by default.
* You can access that instance via `Yii::$app->user`.
*
* You can modify its configuration by adding an array to your application config under `components`
* as it is shown in the following example:
*
* ~~~
* 'user' => [
* 'identityClass' => 'app\models\User', // User must implement the IdentityInterface
* 'enableAutoLogin' => true,
* // 'loginUrl' => ['user/login'],
* // ...
* ]
* ~~~
*
* @property string|integer $id The unique identifier for the user. If null, it means the user is a guest.
* This property is read-only.
* @property IdentityInterface $identity The identity object associated with the currently logged user. Null
...
...
@@ -129,8 +144,8 @@ class User extends Component
* Returns the identity object associated with the currently logged user.
* @return IdentityInterface the identity object associated with the currently logged user.
* Null is returned if the user is not logged in (not authenticated).
* @see login
* @see logout
* @see login
()
* @see logout
()
*/
public
function
getIdentity
()
{
...
...
@@ -139,7 +154,7 @@ class User extends Component
if
(
$id
===
null
)
{
$this
->
_identity
=
null
;
}
else
{
/** @var
$class IdentityInterface
*/
/** @var
IdentityInterface $class
*/
$class
=
$this
->
identityClass
;
$this
->
_identity
=
$class
::
findIdentity
(
$id
);
}
...
...
@@ -202,7 +217,7 @@ class User extends Component
$data
=
json_decode
(
$value
,
true
);
if
(
count
(
$data
)
===
3
&&
isset
(
$data
[
0
],
$data
[
1
],
$data
[
2
]))
{
list
(
$id
,
$authKey
,
$duration
)
=
$data
;
/** @var
$class IdentityInterface
*/
/** @var
IdentityInterface $class
*/
$class
=
$this
->
identityClass
;
$identity
=
$class
::
findIdentity
(
$id
);
if
(
$identity
!==
null
&&
$identity
->
validateAuthKey
(
$authKey
))
{
...
...
@@ -266,7 +281,7 @@ class User extends Component
* If this is null and the return URL was not set previously, [[Application::homeUrl]] will be redirected to.
* Please refer to [[setReturnUrl()]] on accepted format of the URL.
* @return string the URL that the user should be redirected to after login.
* @see loginRequired
* @see loginRequired
()
*/
public
function
getReturnUrl
(
$defaultUrl
=
null
)
{
...
...
@@ -413,7 +428,7 @@ class User extends Component
* information in the cookie.
* @param IdentityInterface $identity
* @param integer $duration number of seconds that the user can remain in logged-in status.
* @see loginByCookie
* @see loginByCookie
()
*/
protected
function
sendIdentityCookie
(
$identity
,
$duration
)
{
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/View.php
View file @
2d866186
...
...
@@ -22,6 +22,22 @@ use yii\base\InvalidConfigException;
*
* View provides a set of methods (e.g. [[render()]]) for rendering purpose.
*
* View is configured as an application component in [[yii\base\Application]] by default.
* You can access that instance via `Yii::$app->view`.
*
* You can modify its configuration by adding an array to your application config under `components`
* as it is shown in the following example:
*
* ~~~
* 'view' => [
* 'theme' => 'app\themes\MyTheme',
* 'renderers' => [
* // you may add Smarty or Twig renderer here
* ]
* // ...
* ]
* ~~~
*
* @property \yii\web\AssetManager $assetManager The asset manager. Defaults to the "assetManager" application
* component.
*
...
...
@@ -72,7 +88,7 @@ class View extends \yii\base\View
/**
* @var AssetBundle[] list of the registered asset bundles. The keys are the bundle names, and the values
* are the registered [[AssetBundle]] objects.
* @see registerAssetBundle
* @see registerAssetBundle
()
*/
public
$assetBundles
=
[];
/**
...
...
@@ -81,32 +97,32 @@ class View extends \yii\base\View
public
$title
;
/**
* @var array the registered meta tags.
* @see registerMetaTag
* @see registerMetaTag
()
*/
public
$metaTags
;
/**
* @var array the registered link tags.
* @see registerLinkTag
* @see registerLinkTag
()
*/
public
$linkTags
;
/**
* @var array the registered CSS code blocks.
* @see registerCss
* @see registerCss
()
*/
public
$css
;
/**
* @var array the registered CSS files.
* @see registerCssFile
* @see registerCssFile
()
*/
public
$cssFiles
;
/**
* @var array the registered JS code blocks
* @see registerJs
* @see registerJs
()
*/
public
$js
;
/**
* @var array the registered JS files.
* @see registerJsFile
* @see registerJsFile
()
*/
public
$jsFiles
;
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/XmlResponseFormatter.php
View file @
2d866186
...
...
@@ -17,6 +17,8 @@ use yii\helpers\StringHelper;
/**
* XmlResponseFormatter formats the given data into an XML response content.
*
* It is used by [[Response]] to format response data.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/web/YiiAsset.php
View file @
2d866186
...
...
@@ -8,6 +8,8 @@
namespace
yii\web
;
/**
* This asset bundle provides the base javascript files for the Yii Framework.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
This diff is collapsed.
Click to expand it.
framework/yii/widgets/ActiveForm.php
View file @
2d866186
...
...
@@ -220,7 +220,7 @@ class ActiveForm extends Widget
$lines
=
[];
foreach
(
$models
as
$model
)
{
/** @var
$model M
odel */
/** @var
Model $m
odel */
foreach
(
$model
->
getFirstErrors
()
as
$error
)
{
$lines
[]
=
Html
::
encode
(
$error
);
}
...
...
This diff is collapsed.
Click to expand it.
framework/yii/widgets/Menu.php
View file @
2d866186
...
...
@@ -104,7 +104,7 @@ class Menu extends Widget
/**
* @var boolean whether to automatically activate items according to whether their route setting
* matches the currently requested route.
* @see isItemActive
* @see isItemActive
()
*/
public
$activateItems
=
true
;
/**
...
...
@@ -137,14 +137,14 @@ class Menu extends Widget
* @var string the route used to determine if a menu item is active or not.
* If not set, it will use the route of the current request.
* @see params
* @see isItemActive
* @see isItemActive
()
*/
public
$route
;
/**
* @var array the parameters used to determine if a menu item is active or not.
* If not set, it will use `$_GET`.
* @see route
* @see isItemActive
* @see isItemActive
()
*/
public
$params
;
...
...
This diff is collapsed.
Click to expand it.
tests/unit/data/views/layout.php
View file @
2d866186
<?php
/**
* @var
$this \yii\web\View
* @var
$content string
* @var
\yii\web\View $this
* @var
string $content
*/
?>
<?php
$this
->
beginPage
();
?>
...
...
@@ -19,4 +19,4 @@
<?php
$this
->
endBody
();
?>
</body>
</html>
<?php
$this
->
endPage
();
?>
\ No newline at end of file
<?php
$this
->
endPage
();
?>
This diff is collapsed.
Click to expand it.
tests/unit/data/views/rawlayout.php
View file @
2d866186
<?php
/**
* @var
$this \yii\web\View
* @var
\yii\web\View $this
*/
?><?php
$this
->
beginPage
();
?>
1
<?php
$this
->
head
();
?>
2
<?php
$this
->
beginBody
();
?>
3
<?php
$this
->
endBody
();
?>
4
<?php
$this
->
endPage
();
?>
\ No newline at end of file
?><?php
$this
->
beginPage
();
?>
1
<?php
$this
->
head
();
?>
2
<?php
$this
->
beginBody
();
?>
3
<?php
$this
->
endBody
();
?>
4
<?php
$this
->
endPage
();
?>
This diff is collapsed.
Click to expand it.
tests/unit/extensions/swiftmailer/MessageTest.php
View file @
2d866186
...
...
@@ -306,7 +306,7 @@ class MessageTest extends VendorTestCase
$htmlPresent
=
false
;
foreach
(
$messageParts
as
$part
)
{
if
(
!
(
$part
instanceof
\Swift_Mime_Attachment
))
{
/* @var
$part \Swift_Mime_MimeP
art */
/* @var
\Swift_Mime_MimePart $p
art */
if
(
$part
->
getContentType
()
==
'text/plain'
)
{
$textPresent
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/db/ActiveRecordTest.php
View file @
2d866186
...
...
@@ -117,7 +117,7 @@ class ActiveRecordTest extends DatabaseTestCase
public
function
testFindLazy
()
{
/** @var
$customer C
ustomer */
/** @var
Customer $c
ustomer */
$customer
=
Customer
::
find
(
2
);
$orders
=
$customer
->
orders
;
$this
->
assertEquals
(
2
,
count
(
$orders
));
...
...
@@ -137,7 +137,7 @@ class ActiveRecordTest extends DatabaseTestCase
public
function
testFindLazyVia
()
{
/** @var
$order O
rder */
/** @var
Order $o
rder */
$order
=
Order
::
find
(
1
);
$this
->
assertEquals
(
1
,
$order
->
id
);
$this
->
assertEquals
(
2
,
count
(
$order
->
items
));
...
...
@@ -162,7 +162,7 @@ class ActiveRecordTest extends DatabaseTestCase
public
function
testFindLazyViaTable
()
{
/** @var
$order O
rder */
/** @var
Order $o
rder */
$order
=
Order
::
find
(
1
);
$this
->
assertEquals
(
1
,
$order
->
id
);
$this
->
assertEquals
(
2
,
count
(
$order
->
books
));
...
...
This diff is collapsed.
Click to expand it.
tests/unit/framework/validators/ValidatorTest.php
View file @
2d866186
...
...
@@ -30,7 +30,7 @@ class ValidatorTest extends TestCase
public
function
testCreateValidator
()
{
$model
=
FakedValidationModel
::
createWithAttributes
([
'attr_test1'
=>
'abc'
,
'attr_test2'
=>
'2013'
]);
/** @var
$numberVal NumberValidator
*/
/** @var
NumberValidator $numberVal
*/
$numberVal
=
TestValidator
::
createValidator
(
'number'
,
$model
,
[
'attr_test1'
]);
$this
->
assertInstanceOf
(
NumberValidator
::
className
(),
$numberVal
);
$numberVal
=
TestValidator
::
createValidator
(
'integer'
,
$model
,
[
'attr_test2'
]);
...
...
@@ -229,4 +229,4 @@ class ValidatorTest extends TestCase
$errors
=
$m
->
getErrors
(
'attr_msg_val'
);
$this
->
assertEquals
(
'attr_msg_val::abc::param_value'
,
$errors
[
0
]);
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
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