/** * Saves the model and its relations. * @param ActiveRecord $model * @return bool * @throws \yii\base\InvalidConfigException */ protected function save($model) { /** @var \nineinchnick\audit\behaviors\TrackableBehavior $trackable */ if (($trackable = $model->getBehavior('trackable')) !== null) { $model->beginChangeset(); } $result = $model->save(false) && $model->saveRelations(Yii::$app->getRequest()->getBodyParams()); if ($trackable !== null) { $model->endChangeset(); } return $result; }
/** * @param \netis\crud\db\ActiveRecord $model * * @return null|yii\db\Transaction */ protected function beforeExecute($model) { $trx = null; if ($this->singleTransaction) { $trx = $model->getDb()->getTransaction() === null ? $model->getDb()->beginTransaction() : null; } if ($model->getBehavior('trackable') !== null) { $model->beginChangeset(); } return $trx; }