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
9c9d11ae
Commit
9c9d11ae
authored
May 29, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
guide WIP [skip ci]
parent
dee3f0f6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
3 deletions
+46
-3
README.md
docs/guide/README.md
+3
-2
structure-applications.md
docs/guide/structure-applications.md
+1
-1
structure-controllers.md
docs/guide/structure-controllers.md
+0
-0
structure-filters.md
docs/guide/structure-filters.md
+42
-0
No files found.
docs/guide/README.md
View file @
9c9d11ae
...
@@ -33,9 +33,10 @@ Application Structure
...
@@ -33,9 +33,10 @@ Application Structure
*
[
Entry Scripts
](
structure-entry-scripts.md
)
*
[
Entry Scripts
](
structure-entry-scripts.md
)
*
[
Applications
](
structure-applications.md
)
*
[
Applications
](
structure-applications.md
)
*
[
Application Components
](
structure-application-components.md
)
*
[
Application Components
](
structure-application-components.md
)
*
[
Controllers
and Actions
](
structure-controllers.md
)
*
[
Controllers
](
structure-controllers.md
)
*
[
Views
](
structure-views.md
)
*
[
Views
](
structure-views.md
)
*
[
Models
](
structure-models.md
)
*
[
Models
](
structure-models.md
)
*
**TBD**
[
Filters
](
structure-filters.md
)
*
**TBD**
[
Widgets
](
structure-widgets.md
)
*
**TBD**
[
Widgets
](
structure-widgets.md
)
*
**TBD**
[
Modules
](
structure-modules.md
)
*
**TBD**
[
Modules
](
structure-modules.md
)
*
**TBD**
[
Extensions
](
structure-extensions.md
)
*
**TBD**
[
Extensions
](
structure-extensions.md
)
...
@@ -50,7 +51,7 @@ Handling Requests
...
@@ -50,7 +51,7 @@ Handling Requests
*
**TBD**
[
Responses
](
runtime-responses.md
)
*
**TBD**
[
Responses
](
runtime-responses.md
)
*
**TBD**
[
Sessions and Cookies
](
runtime-sessions-cookies.md
)
*
**TBD**
[
Sessions and Cookies
](
runtime-sessions-cookies.md
)
*
[
URL Parsing and Generation
](
runtime-url-handling.md
)
*
[
URL Parsing and Generation
](
runtime-url-handling.md
)
*
**TBD**
[
Filtering
](
runtime-filtering.md
)
Key Concepts
Key Concepts
...
...
docs/guide/structure-applications.md
View file @
9c9d11ae
...
@@ -217,7 +217,7 @@ specific controllers. In the following example, `account` will be mapped to
...
@@ -217,7 +217,7 @@ specific controllers. In the following example, `account` will be mapped to
'account'
=>
'app\controllers\UserController'
,
'account'
=>
'app\controllers\UserController'
,
'article'
=>
[
'article'
=>
[
'class'
=>
'app\controllers\PostController'
,
'class'
=>
'app\controllers\PostController'
,
'
pageTitle'
=>
'something new'
,
'
enableCsrfValidation'
=>
false
,
],
],
],
],
],
],
...
...
docs/guide/structure-controllers.md
View file @
9c9d11ae
This diff is collapsed.
Click to expand it.
docs/guide/structure-filters.md
0 → 100644
View file @
9c9d11ae
You may apply some action filters to controller actions to accomplish tasks such as determining
who can access the current action, decorating the result of the action, etc.
An action filter is an instance of a class extending
[
[yii\base\ActionFilter
]
].
To use an action filter, attach it as a behavior to a controller or a module. The following
example shows how to enable HTTP caching for the
`index`
action:
```
php
public
function
behaviors
()
{
return
[
'httpCache'
=>
[
'class'
=>
\yii\filters\HttpCache
::
className
(),
'only'
=>
[
'index'
],
'lastModified'
=>
function
(
$action
,
$params
)
{
$q
=
new
\yii\db\Query
();
return
$q
->
from
(
'user'
)
->
max
(
'updated_at'
);
},
],
];
}
```
You may use multiple action filters at the same time. These filters will be applied in the
order they are declared in
`behaviors()`
. If any of the filter cancels the action execution,
the filters after it will be skipped.
When you attach a filter to a controller, it can be applied to all actions of that controller;
If you attach a filter to a module (or application), it can be applied to the actions of any controller
within that module (or application).
To create a new action filter, extend from
[
[yii\base\ActionFilter
]
] and override the
[
[yii\base\ActionFilter::beforeAction()|beforeAction()
]
] and
[
[yii\base\ActionFilter::afterAction()|afterAction()
]
]
methods. The former will be executed before an action runs while the latter after an action runs.
The return value of
[
[yii\base\ActionFilter::beforeAction()|beforeAction()
]
] determines whether
an action should be executed or not. If
`beforeAction()`
of a filter returns false, the filters after this one
will be skipped and the action will not be executed.
The
[
authorization
](
authorization.md
)
section of this guide shows how to use the
[
[yii\filters\AccessControl
]
] filter,
and the
[
caching
](
caching.md
)
section gives more details about the
[
[yii\filters\PageCache
]
] and
[
[yii\filters\HttpCache
]
] filters.
These built-in filters are also good references when you learn to create your own filters.
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