I have a question about Behaviors.
If I create a custom behavior B with methods B.beforeSave(), B.afterFind(), and B.someFunction(), is there a way that my model M could specifically make a call to B.someFunction()?
Is it possible to get the Behavior objects from within my model and make the call directly?
Page 1 of 1
Additional Behavior Methods
#2
Posted 22 April 2010 - 11:49 AM
Yes. This is commonly used when two or more behaviors with the same name and different parameters are assigned to a model.
class Product extends CActiveRecord {
function behaviors(){
return array(
'internalColor' => array(
'class' => 'ext.yiiext.behaviors.model.taggable.ETaggableBehaviour',
),
'externalColor' => array(
'class' => 'ext.yiiext.behaviors.model.taggable.ETaggableBehaviour',
),
);
}
}
$product->internalColor->myBehaviorMethod(); $product->externalColor->myBehaviorMethod();
#3
Posted 22 April 2010 - 05:22 PM
Thank you for your help.
Your answers solves my question completely.
Your answers solves my question completely.
Share this topic:
Page 1 of 1

Help













