本文整理汇总了PHP中yii\db\BaseActiveRecord::getBehaviors方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseActiveRecord::getBehaviors方法的具体用法?PHP BaseActiveRecord::getBehaviors怎么用?PHP BaseActiveRecord::getBehaviors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\BaseActiveRecord
的用法示例。
在下文中一共展示了BaseActiveRecord::getBehaviors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isAttachedTo
/**
* Tests that a `SimpleWorkflowBehavior` behavior is attached to the object passed as argument.
*
* This method returns FALSE if $model is not an instance of BaseActiveRecord (has SimpleWorkflowBehavior can only be attached
* to instances of this class) or if none of its attached behaviors is a or inherit from SimpleWorkflowBehavior.
*
* @param BaseActiveRecord $model the model to test.
* @return boolean TRUE if at least one SimpleWorkflowBehavior behavior is attached to $model, FALSE otherwise
*/
public static function isAttachedTo($model)
{
if ($model instanceof yii\base\Component) {
foreach ($model->getBehaviors() as $behavior) {
if ($behavior instanceof SimpleWorkflowBehavior) {
return true;
}
}
} else {
throw new WorkflowException('Invalid argument type : $model must be a BaseActiveRecord');
}
return false;
}