'beforeSave', ActiveRecord::EVENT_BEFORE_UPDATE => 'beforeSave', ActiveRecord::EVENT_AFTER_INSERT => 'afterSave', ActiveRecord::EVENT_AFTER_UPDATE => 'afterSave', ]; } public function beforeSave($event) { /** * @var ActiveRecord $owner */ $owner = $this->owner; $db = $owner::getDb(); $this->_transaction = $db->beginTransaction(); } public function afterSave($event) { /** * @var ActiveRecord $owner */ $owner = $this->owner; if(!empty($this->model_langs) && $owner->getBehavior('language')) { if($owner->linkLangs($this->model_langs) && $owner->saveLangs($this->model_langs)) { $this->_transaction->commit(); $this->_transaction_status = true; } else { $this->_transaction->rollBack(); $this->_transaction_status = false; } } else { $this->_transaction->commit(); $this->_transaction_status = true; } } /** * @return bool */ public function getTransactionStatus():bool { return $this->_transaction_status; } }