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
2f3cc8f1
Commit
2f3cc8f1
authored
Mar 25, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished ActionFilter.
parent
392b293d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
21 deletions
+40
-21
ActionFilter.php
framework/base/ActionFilter.php
+40
-4
todo.md
todo.md
+0
-17
No files found.
framework/base/ActionFilter.php
View file @
2f3cc8f1
...
...
@@ -30,8 +30,8 @@ class ActionFilter extends Behavior
public
function
events
()
{
return
array
(
'beforeAction'
=>
'before
Action
'
,
'afterAction'
=>
'after
Action
'
,
'beforeAction'
=>
'before
Filter
'
,
'afterAction'
=>
'after
Filter
'
,
);
}
...
...
@@ -39,8 +39,11 @@ class ActionFilter extends Behavior
* @param ActionEvent $event
* @return boolean
*/
public
function
before
Action
(
$event
)
public
function
before
Filter
(
$event
)
{
if
(
$this
->
isActive
(
$event
->
action
))
{
$event
->
isValid
=
$this
->
beforeAction
(
$event
->
action
);
}
return
$event
->
isValid
;
}
...
...
@@ -48,8 +51,40 @@ class ActionFilter extends Behavior
* @param ActionEvent $event
* @return boolean
*/
public
function
after
Action
(
$event
)
public
function
after
Filter
(
$event
)
{
if
(
$this
->
isActive
(
$event
->
action
))
{
$this
->
afterAction
(
$event
->
action
);
}
}
/**
* This method is invoked right before an action is to be executed (after all possible filters.)
* You may override this method to do last-minute preparation for the action.
* @param Action $action the action to be executed.
* @return boolean whether the action should continue to be executed.
*/
public
function
beforeAction
(
$action
)
{
return
true
;
}
/**
* This method is invoked right after an action is executed.
* You may override this method to do some postprocessing for the action.
* @param Action $action the action just executed.
*/
public
function
afterAction
(
$action
)
{
}
/**
* Returns a value indicating whether the filer is active for the given action.
* @param Action $action the action being filtered
* @return boolean whether the filer is active for the given action.
*/
protected
function
isActive
(
$action
)
{
return
!
in_array
(
$action
->
id
,
$this
->
except
,
true
)
&&
(
empty
(
$this
->
only
)
||
in_array
(
$action
->
id
,
$this
->
only
,
true
));
}
}
\ No newline at end of file
todo.md
View file @
2f3cc8f1
-
console
*
If console is executed using Windows, do not use colors. If not, use colors. Allow to override via console application settings.
-
db
*
pgsql, sql server, oracle, db2 drivers
*
unit tests on different DB drivers
*
document-based (should allow storage-specific methods additionally to generic ones)
*
mongodb (put it under framework/db/mongodb)
*
key-value-based (should allow storage-specific methods additionally to generic ones)
*
redis (put it under framework/db/redis or perhaps framework/caching?)
-
base
*
TwigViewRenderer (Alex)
*
SmartyViewRenderer (Alex)
-
logging
*
WebTarget (TBD after web is in place): should consider using javascript and make it into a toolbar
*
ProfileTarget (TBD after web is in place): should consider using javascript and make it into a toolbar
*
unit tests
-
caching
*
backend-specific unit tests
*
dependency unit tests
-
validators
*
Refactor validators to add validateValue() for every validator, if possible. Check if value is an array.
...
...
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