Commit 2f3cc8f1 by Qiang Xue

finished ActionFilter.

parent 392b293d
......@@ -30,8 +30,8 @@ class ActionFilter extends Behavior
public function events()
{
return array(
'beforeAction' => 'beforeAction',
'afterAction' => 'afterAction',
'beforeAction' => 'beforeFilter',
'afterAction' => 'afterFilter',
);
}
......@@ -39,8 +39,11 @@ class ActionFilter extends Behavior
* @param ActionEvent $event
* @return boolean
*/
public function beforeAction($event)
public function beforeFilter($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 afterAction($event)
public function afterFilter($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
- 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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment