isAttachedTo() public static method

This method returns FALSE if $model is not an instance of yii\base\Component or if none of its attached behaviors is a or inherit from SimpleWorkflowBehavior.
public static isAttachedTo ( BaseActiveRecord $model ) : boolean
$model yii\db\BaseActiveRecord the model to test.
return boolean TRUE if at least one SimpleWorkflowBehavior behavior is attached to $model, FALSE otherwise
 /**
  * (non-PHPdoc)
  * @see \yii\base\Object::init()
  */
 public function init()
 {
     parent::init();
     if (!isset($this->containerId)) {
         throw new InvalidConfigException("Parameter 'containerId' is missing ");
     }
     if (!isset($this->visNetworkId)) {
         $this->visNetworkId = uniqid('vis_');
     }
     if (!isset($this->workflow)) {
         throw new InvalidConfigException("Parameter 'workflow' is missing ");
     }
     if ($this->workflow instanceof \yii\base\Model) {
         if (!\raoul2000\workflow\base\SimpleWorkflowBehavior::isAttachedTo($this->workflow)) {
             throw new InvalidConfigException("The model passed as parameter 'workflow' is not attached to a SimpleWorkflowBehavior.");
         }
         $this->_workflow = $this->workflow->getWorkflow();
         if ($this->_workflow == null) {
             $this->_workflow = $this->workflow->getWorkflowSource()->getWorkflow($this->workflow->getDefaultWorkflowId());
         }
     } elseif ($this->workflow instanceof \raoul2000\workflow\base\WorkflowInterface) {
         $this->_workflow = $this->workflow;
     }
     if ($this->_workflow == null) {
         throw new InvalidConfigException("Failed to find workflow instance from parameter 'workflow'");
     }
     $this->_visId = uniqid();
 }
 public function testAttachFails2()
 {
     $this->specify('the status attribute cannot be empty', function () {
         $model = new Item01();
         expect('model has a SimpleWorkflowBehavior attached', SimpleWorkflowBehavior::isAttachedTo($model))->true();
         $model->detachBehavior('workflow');
         expect('model has a NO SimpleWorkflowBehavior attached', SimpleWorkflowBehavior::isAttachedTo($model))->false();
         $model->attachBehavior('workflow', ['class' => SimpleWorkflowBehavior::className(), 'statusAttribute' => '']);
     }, ['throws' => 'yii\\base\\InvalidConfigException']);
 }
 /**
  * Returns an associative array containing all statuses that can be reached by model.
  * 
  * 
  * @param BaseActiveRecord $model
  * @param boolean $validate when TRUE only those status with successfull attribute validation are included. When FALSE (default)
  * Attribute validation is done performed.
  * @param boolean $beforeEvents when TRUE all configured *before* events are fired : only the status that don't invalidate the
  * workflow event are included in the returned array, otherwise no event is fired and all next status are included 
  * @param boolean $includeCurrent when TRUE the current model status is added to the returned array. When FALSE (default)
  * only next statuses are included
  * @throws WorkflowException
  * @return array
  */
 public static function getNextStatusListData($model, $validate = false, $beforeEvents = false, $includeCurrent = false)
 {
     if (!SimpleWorkflowBehavior::isAttachedTo($model)) {
         throw new WorkflowException('The model does not have a SimpleWorkflowBehavior behavior');
     }
     $listData = [];
     if ($includeCurrent) {
         $currentStatus = $model->getWorkflowStatus();
         $listData[$currentStatus->getId()] = $currentStatus->getLabel();
     }
     $report = $model->getNextStatuses($validate, $beforeEvents);
     foreach ($report as $endStatusId => $info) {
         if (!isset($info['isValid']) || $info['isValid'] === true) {
             $listData[$endStatusId] = $info['status']->getLabel();
         }
     }
     return $listData;
 }
 /**
  * Apply active validators for the current workflow event sequence.
  *
  * If a workflow event sequence is about to occur, this method scan all validators defined in the
  * owner model, and applies the ones which are valid for the upcomming events.
  *
  * @see \raoul2000\workflow\events\IEventSequence
  */
 public function validateAttribute($object, $attribute)
 {
     if (!SimpleWorkflowBehavior::isAttachedTo($object)) {
         throw new WorkflowException('Validation error : the model does not have the SimpleWorkflowBehavior');
     }
     try {
         $scenarioList = $object->getScenarioSequence($object->{$attribute});
     } catch (WorkflowException $e) {
         $object->addError($attribute, 'Workflow validation failed : ' . $e->getMessage());
         $scenarioList = [];
     }
     if (count($scenarioList) != 0) {
         foreach ($object->getValidators() as $validator) {
             foreach ($scenarioList as $scenario) {
                 if ($this->_isActiveValidator($validator, $scenario)) {
                     $validator->validateAttributes($object);
                 }
             }
         }
     }
 }