account = $account; parent::__construct($config); } /** * @return Account */ public function getAccount() : Account { return $this->account; } public function changeEmail() : bool { if (!$this->validate()) { return false; } $transaction = Yii::$app->db->beginTransaction(); try { /** @var \common\models\confirmations\NewEmailConfirmation $activation */ $activation = $this->getActivationCodeModel(); $activation->delete(); $account = $this->getAccount(); $account->email = $activation->newEmail; if (!$account->save()) { throw new ErrorException('Cannot save new account email value'); } $transaction->commit(); } catch (Exception $e) { $transaction->rollBack(); throw $e; } return true; } }