コード例 #1
0
 /**
  * Tests that a ActiveWorkflowBehavior behavior is attached to the object passed as argument.
  *
  * This method returns FALSE if $model is not an instance of BaseActiveRecord (has ActiveWorkflowBehavior can only be attached
  * to instances of this class) or if none of its attached behaviors is a or inherit from ActiveWorkflowBehavior.
  *
  * @param Model|ActiveWorkflowBehavior $model the model to test.
  * @return bool TRUE if at least one ActiveWorkflowBehavior behavior is attached to $model, FALSE otherwise
  * @throws WorkflowException
  */
 public static function isAttachedTo($model)
 {
     if ($model instanceof Model) {
         foreach ($model->getBehaviors() as $behavior) {
             if ($behavior instanceof ActiveWorkflowBehavior) {
                 return true;
             }
         }
     } else {
         throw new WorkflowException('Invalid argument type : $model must be an instance of yii\\base\\Model');
     }
     return false;
 }