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
60b38a1a
Commit
60b38a1a
authored
Jun 21, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished filter section [skip ci]
parent
02e37460
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
14 deletions
+40
-14
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
HttpCache.php
framework/filters/HttpCache.php
+3
-3
PageCache.php
framework/filters/PageCache.php
+3
-4
No files found.
docs/guide/concept-behaviors.md
View file @
60b38a1a
...
@@ -136,8 +136,20 @@ $component->attachBehaviors([
...
@@ -136,8 +136,20 @@ $component->attachBehaviors([
]);
]);
```
```
You may also attach behaviors through
[
configurations
](
concept-configurations.md
)
. For more details, please
You may also attach behaviors through
[
configurations
](
concept-configurations.md
)
like the following. For more details,
refer to the
[
Configurations
](
concept-configurations.md#configuration-format
)
section.
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>
Detaching Behaviors <a name="detaching-behaviors"></a>
...
...
docs/guide/concept-events.md
View file @
60b38a1a
...
@@ -162,6 +162,18 @@ $foo->on(Foo::EVENT_HELLO, function ($event) {
...
@@ -162,6 +162,18 @@ $foo->on(Foo::EVENT_HELLO, function ($event) {
},
$data
,
false
);
},
$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>
Detaching Event Handlers <a name="detaching-event-handlers"></a>
------------------------
------------------------
...
...
docs/guide/structure-controllers.md
View file @
60b38a1a
...
@@ -2,10 +2,13 @@ Controllers
...
@@ -2,10 +2,13 @@ Controllers
===========
===========
Controllers are part of the
[
MVC
](
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
)
architecture.
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
They are objects of classes extending from
[
[yii\base\Controller
]
] and are responsible for processing requests and
taking over the control from
[
applications
](
structure-applications.md
)
, controllers will analyze incoming request data,
generating responses. In particular, after taking over the control from
[
applications
](
structure-applications.md
)
,
pass them to
[
models
](
structure-models.md
)
, inject model results into
[
views
](
structure-views.md
)
,
controllers will analyze incoming request data, pass them to
[
models
](
structure-models.md
)
, inject model results
and finally generate outgoing responses.
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
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.
execution. A controller can have one or multiple actions.
...
...
docs/guide/structure-filters.md
View file @
60b38a1a
This diff is collapsed.
Click to expand it.
docs/internals/translation-status.md
View file @
60b38a1a
...
@@ -21,7 +21,7 @@ structure-controllers.md | Yes
...
@@ -21,7 +21,7 @@ structure-controllers.md | Yes
structure-views.md | Yes
structure-views.md | Yes
structure-models.md | Yes
structure-models.md | Yes
structure-modules.md | Yes
structure-modules.md | Yes
structure-filters.md |
structure-filters.md |
Yes
structure-widgets.md |
structure-widgets.md |
structure-assets.md |
structure-assets.md |
structure-extensions.md |
structure-extensions.md |
...
...
framework/filters/HttpCache.php
View file @
60b38a1a
...
@@ -12,11 +12,11 @@ use yii\base\ActionFilter;
...
@@ -12,11 +12,11 @@ use yii\base\ActionFilter;
use
yii\base\Action
;
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.
* 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
* 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.
* 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;
...
@@ -24,7 +24,7 @@ use yii\base\Action;
* public function behaviors()
* public function behaviors()
* {
* {
* return [
* return [
*
'httpCache' =>
[
* [
* 'class' => 'yii\filters\HttpCache',
* 'class' => 'yii\filters\HttpCache',
* 'only' => ['index'],
* 'only' => ['index'],
* 'lastModified' => function ($action, $params) {
* 'lastModified' => function ($action, $params) {
...
...
framework/filters/PageCache.php
View file @
60b38a1a
...
@@ -13,15 +13,14 @@ use yii\base\Action;
...
@@ -13,15 +13,14 @@ use yii\base\Action;
use
yii\caching\Dependency
;
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.
* 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.
* 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.
* 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),
* It also stores different versions of the page depending on the application language.
* the application language and user id.
*
*
* ~~~
* ~~~
* public function behaviors()
* public function behaviors()
...
...
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