Browse Source

Added `beforeRun()` and `afterRun()` to `yii\base\Action`

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
a5968a6ac6
  1. 1
      framework/CHANGELOG.md
  2. 19
      framework/base/Action.php

1
framework/CHANGELOG.md

@ -94,6 +94,7 @@ Yii Framework 2 Change Log
- Enh: yii\codeception\TestCase now supports loading and using fixtures via Yii fixture framework (qiangxue)
- Enh: Added support to parse json request data to Request::getRestParams() (cebe)
- Enh: Added ability to get incoming headers (dizews)
- Enh: Added `beforeRun()` and `afterRun()` to `yii\base\Action` (qiangxue)
- Chg #1519: `yii\web\User::loginRequired()` now returns the `Response` object instead of exiting the application (qiangxue)
- Chg #1586: `QueryBuilder::buildLikeCondition()` will now escape special characters and use percentage characters by default (qiangxue)
- Chg #1610: `Html::activeCheckboxList()` and `Html::activeRadioList()` will submit an empty string if no checkbox/radio is selected (qiangxue)

19
framework/base/Action.php

@ -86,4 +86,23 @@ class Action extends Component
}
return call_user_func_array([$this, 'run'], $args);
}
/**
* This method is called right before `run()` is executed.
* You may override this method to do preparation work for the action run.
* If the method returns false, it will cancel the action.
* @return boolean whether to run the action.
*/
protected function beforeRun()
{
return true;
}
/**
* This method is called right after `run()` is executed.
* You may override this method to do post-processing work for the action run.
*/
protected function afterRun()
{
}
}

Loading…
Cancel
Save