I use this feature to implement alot of project-specific business logics
without modification of yii-user module at each project, this is critically
important feature and it would be great to add it to Yii-user.
Patch:
1) Add to UActiveRecord:
public function behaviors(){return
Yii::app()->getModule('user')->getBehaviorsFor(get_class($this));}
(or Yii::app()->getController()->getModule() instead of
Yii::app()->getModule('user') to remove depencency from module name, this
variant isn't tested by me, first variant works well)
2) Add to user module:
public $componentBehaviors=array();
public function getBehaviorsFor($componentName){
if (isset($this->componentBehaviors[$componentName]))
{
return $this->componentBehaviors[$componentName];
}else{
return array();
}
}
3) We can configure it:
'user'=>array(
'class'=>'application.modules.user.UserModule',
'componentBehaviors'=>array(
'Profile'=>array(
'myProjectSpecificBusinessLogics'=>array('class'=>'Proj130UserBehavior'),
),
),
),
In beaviors I usually implement events such as afterSave, beforeValidate, etc.
Original issue reported on code.google.com by vitaliy.step on 24 Jan 2011 at 9:53
Original issue reported on code.google.com by
vitaliy.step
on 24 Jan 2011 at 9:53