/**
  * @throws InvalidSchemaException
  * @throws TransitionException
  * @throws \yii\db\Exception
  * @throws exceptions\StateNotFoundException
  */
 public function initStateMachine()
 {
     $this->owner->off(ActiveRecord::EVENT_AFTER_INSERT, [$this, 'initStateMachine']);
     // If value already set then ignore the call
     $context = $this->createContext();
     $this->sm->initStateMachineAttribute($context);
     return $context;
 }