Reputation: 11
I have to translate an applications from Zend to Yii Framework. Since i'm new to Zend, i wonder how to implement the Controllers preDispatch() and init() functions in Yii. Thanks for advice.
Upvotes: 1
Views: 241
Reputation:
For init there is same init
function in Yii controllers.
public function init()
{
// Do some initialization
}
For predispatch you can use beforeAction
, this will be called just before action - return true if you want action to be executed, or false to cancel execution.
protected function beforeAction($action) {
// Do some logic just before action
return true;
}
When ovveriding custom controller parent methods should be called.
There is also very usefull filter for actions
Upvotes: 2