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\BaseObject) {
			if(   ! $this->owner->hasProperty($this->statusAttribute) ) {
				throw new InvalidConfigException('Property not found for owner model : \''.$this->statusAttribute.'\'');
			}			
		}
		
		$this->initStatus();
		if( ! $this->hasWorkflowStatus()) {
			$this->doAutoInsert();
		}
	}
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\BaseObject) {
			if(   ! $this->owner->hasProperty($this->statusAttribute) ) {
				throw new InvalidConfigException('Property not found for owner model : \''.$this->statusAttribute.'\'');
			}			
		}
		
		$this->initStatus();
		if( ! $this->hasWorkflowStatus()) {
			$this->doAutoInsert();
		}
	}
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 \ BaseObject ) { if ( ! $ this -> owner -> hasProperty ( $ this -> statusAttribute ) ) { throw new InvalidConfigException ( 'Property not found for owner model : \'' . $ this -> statusAttribute . '\'' ) ; } } $ this -> initStatus ( ) ; if ( ! $ this -> hasWorkflowStatus ( ) ) { $ this -> doAutoInsert ( ) ; } }
Attaches the behavior to the model.

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.

@see http://www.yiiframework.com/doc-2.0/yii-base-behavior.html#attach()-detail
@see initStatus()
Attaches the behavior to the model .