raoul2000\workflow\base\SimpleWorkflowBehavior::attach PHP Метод

attach() публичный Метод

The operation is successful if the owner component has the appropriate attribute or property to store the workflow status value. The name of this attribute or property is set to 'status' by default, but can be configured using the statusAttribute configuration parameter at construction time. Note that using a property instead of a model attribute to store the status value is not recomended as it is then the developer responsability to ensure that the workflow operations are consistent, in particular regarding persistence. If previous requirements are met, the internal status value is initialized.
См. также: http://www.yiiframework.com/doc-2.0/yii-base-behavior.html#attach()-detail
См. также: initStatus()
public attach ( $owner )
    public function attach($owner)
    {
        parent::attach($owner);
        if ($this->owner instanceof \yii\db\BaseActiveRecord) {
            if (!$this->owner->hasAttribute($this->statusAttribute) && !$this->owner->hasProperty($this->statusAttribute)) {
                throw new InvalidConfigException('Attribute or property not found for owner model : \'' . $this->statusAttribute . '\'');
            }
        } elseif ($this->owner instanceof \yii\base\Object) {
            if (!$this->owner->hasProperty($this->statusAttribute)) {
                throw new InvalidConfigException('Property not found for owner model : \'' . $this->statusAttribute . '\'');
            }
        }
        $this->initStatus();
        if (!$this->hasWorkflowStatus()) {
            $this->doAutoInsert();
        }
    }