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
effd47db
Commit
effd47db
authored
Jun 22, 2014
by
Abderrahim Bajja
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master'
Update from remote
parents
8dead867
60b38a1a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
87 additions
and
21 deletions
+87
-21
caching-overview.md
docs/guide-ru/caching-overview.md
+19
-0
concept-behaviors.md
docs/guide/concept-behaviors.md
+14
-2
concept-events.md
docs/guide/concept-events.md
+12
-0
structure-controllers.md
docs/guide/structure-controllers.md
+7
-4
structure-filters.md
docs/guide/structure-filters.md
+0
-0
translation-status.md
docs/internals/translation-status.md
+1
-1
ActiveForm.php
extensions/bootstrap/ActiveForm.php
+0
-0
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
HttpCache.php
framework/filters/HttpCache.php
+3
-3
PageCache.php
framework/filters/PageCache.php
+3
-4
BaseInflector.php
framework/helpers/BaseInflector.php
+1
-1
Session.php
framework/web/Session.php
+2
-1
InflectorTest.php
tests/unit/framework/helpers/InflectorTest.php
+1
-1
BreadcrumbsTest.php
tests/unit/framework/widgets/BreadcrumbsTest.php
+23
-4
No files found.
docs/guide-ru/caching-overview.md
0 → 100644
View file @
effd47db
Кэширование
=======
Кэширование — это простой и эффективный способ повысить производительность веб-приложения. Сохраняя относительно
статичные данные в кэше и извлекая их из кэша, когда потребуется, мы экономим время, затрачиваемое на генерацию
данных с нуля каждый раз.
Кэширование может использоваться на различных уровнях веб-приложения. На стороне сервера, на более низшем уровне мы
используем кэширование для хранения основных данных, таких как список последних статьей запрашиваемых из базы данных;
и на более высоком уровне, кэш может использоваться для хранения фрагментов или целых веб-страниц, например как результат
рендеринга последних статьей. На стороне клиента может использоваться HTTP-кэширование, чтобы сохранить содержимое
недавно посещенных страниц в кэше браузера.
Yii поддерживает все эти механизмы кэширования:
*
[
Кэширование данных
](
caching-data.md
)
*
[
Кэширование фрагментов
](
caching-fragment.md
)
*
[
Кэширование страниц
](
caching-page.md
)
*
[
HTTP-кэширование
](
caching-http.md
)
docs/guide/concept-behaviors.md
View file @
effd47db
...
...
@@ -136,8 +136,20 @@ $component->attachBehaviors([
]);
```
You may also attach behaviors through
[
configurations
](
concept-configurations.md
)
. For more details, please
refer to the
[
Configurations
](
concept-configurations.md#configuration-format
)
section.
You may also attach behaviors through
[
configurations
](
concept-configurations.md
)
like the following. For more details,
please refer to the
[
Configurations
](
concept-configurations.md#configuration-format
)
section.
```
php
[
'as myBehavior2'
=>
MyBehavior
::
className
(),
'as myBehavior3'
=>
[
'class'
=>
MyBehavior
::
className
(),
'prop1'
=>
'value1'
,
'prop2'
=>
'value2'
,
],
]
```
Detaching Behaviors <a name="detaching-behaviors"></a>
...
...
docs/guide/concept-events.md
View file @
effd47db
...
...
@@ -162,6 +162,18 @@ $foo->on(Foo::EVENT_HELLO, function ($event) {
},
$data
,
false
);
```
Besides calling the
`on()`
method, you may also attach event handlers in
[
configurations
](
concept-configurations.md
)
like the following. For more details, please refer to the
[
Configurations
](
concept-configurations.md#configuration-format
)
section.
```
php
[
'on hello'
=>
function
(
$event
)
{
echo
'hello event is triggered'
;
}
]
```
Detaching Event Handlers <a name="detaching-event-handlers"></a>
------------------------
...
...
docs/guide/structure-controllers.md
View file @
effd47db
...
...
@@ -2,10 +2,13 @@ Controllers
===========
Controllers are part of the
[
MVC
](
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
)
architecture.
They are objects responsible for processing requests and generating responses. In particular, after
taking over the control from
[
applications
](
structure-applications.md
)
, controllers will analyze incoming request data,
pass them to
[
models
](
structure-models.md
)
, inject model results into
[
views
](
structure-views.md
)
,
and finally generate outgoing responses.
They are objects of classes extending from
[
[yii\base\Controller
]
] and are responsible for processing requests and
generating responses. In particular, after taking over the control from
[
applications
](
structure-applications.md
)
,
controllers will analyze incoming request data, pass them to
[
models
](
structure-models.md
)
, inject model results
into
[
views
](
structure-views.md
)
, and finally generate outgoing responses.
## Actions <a name="actions"></a>
Controllers are composed by
*actions*
which are the most basic units that end users can address and request for
execution. A controller can have one or multiple actions.
...
...
docs/guide/structure-filters.md
View file @
effd47db
This diff is collapsed.
Click to expand it.
docs/internals/translation-status.md
View file @
effd47db
...
...
@@ -21,7 +21,7 @@ structure-controllers.md | Yes
structure-views.md | Yes
structure-models.md | Yes
structure-modules.md | Yes
structure-filters.md |
structure-filters.md |
Yes
structure-widgets.md |
structure-assets.md |
structure-extensions.md |
...
...
extensions/bootstrap/ActiveForm.php
View file @
effd47db
framework/CHANGELOG.md
View file @
effd47db
...
...
@@ -51,6 +51,7 @@ Yii Framework 2 Change Log
-
Bug #3909:
`Html::to()`
should not prefix base URL to URLs that already contain scheme (qiangxue)
-
Bug #3934: yii.handleAction() in yii.js does not correctly detect if a hyperlink contains useful URL or not (joni-jones, qiangxue)
-
Bug #3968: Messages logged in shutdown functions are not handled (qiangxue)
-
Bug #3996: Traversing
`Yii::$app->session`
may cause a PHP error (qiangxue)
-
Bug: Fixed inconsistent return of
`\yii\console\Application::runAction()`
(samdark)
-
Bug: URL encoding for the route parameter added to
`\yii\web\UrlManager`
(klimov-paul)
-
Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue)
...
...
framework/filters/HttpCache.php
View file @
effd47db
...
...
@@ -12,11 +12,11 @@ use yii\base\ActionFilter;
use
yii\base\Action
;
/**
*
The HttpCache provides functionality for caching via HTTP Last-Modified and Etag
headers.
*
HttpCache implements client-side caching by utilizing the `Last-Modified` and `Etag` HTTP
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.
* To use
HttpCache
, 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.
*
...
...
@@ -24,7 +24,7 @@ use yii\base\Action;
* public function behaviors()
* {
* return [
*
'httpCache' =>
[
* [
* 'class' => 'yii\filters\HttpCache',
* 'only' => ['index'],
* 'lastModified' => function ($action, $params) {
...
...
framework/filters/PageCache.php
View file @
effd47db
...
...
@@ -13,15 +13,14 @@ use yii\base\Action;
use
yii\caching\Dependency
;
/**
*
The PageCache provides functionality for whole page caching
*
PageCache implements server-side caching of whole pages.
*
* 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
* In the following example the filter will be applied to the `
index`
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.
* It also stores different versions of the page depending on the application language.
*
* ~~~
* public function behaviors()
...
...
framework/helpers/BaseInflector.php
View file @
effd47db
...
...
@@ -415,7 +415,7 @@ class BaseInflector
public
static
function
slug
(
$string
,
$replacement
=
'-'
,
$lowercase
=
true
)
{
$string
=
static
::
transliterate
(
$string
);
$string
=
preg_replace
(
'/[^a-zA-Z=\s—–-]+/u'
,
''
,
$string
);
$string
=
preg_replace
(
'/[^a-zA-Z
0-9
=\s—–-]+/u'
,
''
,
$string
);
$string
=
preg_replace
(
'/[=\s—–-]+/u'
,
$replacement
,
$string
);
$string
=
trim
(
$string
,
$replacement
);
...
...
framework/web/Session.php
View file @
effd47db
...
...
@@ -507,6 +507,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
*/
public
function
getIterator
()
{
$this
->
open
();
return
new
SessionIterator
;
}
...
...
@@ -516,6 +517,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
*/
public
function
getCount
()
{
$this
->
open
();
return
count
(
$_SESSION
);
}
...
...
@@ -539,7 +541,6 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
public
function
get
(
$key
,
$defaultValue
=
null
)
{
$this
->
open
();
return
isset
(
$_SESSION
[
$key
])
?
$_SESSION
[
$key
]
:
$defaultValue
;
}
...
...
tests/unit/framework/helpers/InflectorTest.php
View file @
effd47db
...
...
@@ -126,7 +126,7 @@ class InflectorTest extends TestCase
{
$data
=
[
''
=>
''
,
'hello world
'
=>
'hello-world
'
,
'hello world
123'
=>
'hello-world-123
'
,
'remove.!?[]{}…symbols'
=>
'removesymbols'
,
'minus-sign'
=>
'minus-sign'
,
'mdash—sign'
=>
'mdash-sign'
,
...
...
tests/unit/framework/widgets/BreadcrumbsTest.php
View file @
effd47db
...
...
@@ -13,16 +13,35 @@ use yii\widgets\Breadcrumbs;
class
BreadcrumbsTest
extends
\yiiunit\TestCase
{
private
$breadcrumbs
;
private
$app
;
public
function
setUp
()
{
$this
->
app
=
$this
->
mockApplication
();
Yii
::
setAlias
(
'@testWeb'
,
'/'
);
Yii
::
setAlias
(
'@testWebRoot'
,
'@yiiunit/data/web'
);
// dirty way to have Request object not throwing exception when running testHomeLinkNull()
$_SERVER
[
'SCRIPT_FILENAME'
]
=
"index.php"
;
$_SERVER
[
'SCRIPT_NAME'
]
=
"index.php"
;
$this
->
mockApplication
([],
'yii\web\Application'
);
$this
->
breadcrumbs
=
new
Breadcrumbs
();
}
public
function
testHomeLinkNull
()
{
$this
->
breadcrumbs
->
homeLink
=
null
;
$this
->
breadcrumbs
->
links
=
[
'label'
=>
'My Home Page'
,
'url'
=>
'http://my.example.com/yii2/link/page'
];
$expectedHtml
=
"<ul class=
\"
breadcrumb
\"
><li><a href=
\"
./index.php
\"
>Home</a></li>
\n
"
.
"<li class=
\"
active
\"
>My Home Page</li>
\n
"
.
"<li class=
\"
active
\"
>http://my.example.com/yii2/link/page</li>
\n
"
.
"</ul>"
;
ob_start
();
$this
->
breadcrumbs
->
run
();
$actualHtml
=
ob_get_contents
();
ob_end_clean
();
$this
->
assertEquals
(
$expectedHtml
,
$actualHtml
);
}
public
function
testEmptyLinks
()
{
$this
->
assertNull
(
$this
->
breadcrumbs
->
run
());
...
...
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