account = $account; parent::__construct($config); } public function rules() { return [ ['lang', 'required'], ['lang', LanguageValidator::class], ]; } public function applyLanguage() : bool { if (!$this->validate()) { return false; } $account = $this->getAccount(); $account->lang = $this->lang; if (!$account->save()) { throw new ErrorException('Cannot change user language'); } return true; } public function getAccount() : Account { return $this->account; } }