userId = (int)$this->getUrlParamInt('userId'); } public function handle(): void { if (!$this->isUserLoggedIn() || !$this->hasUserPermission($this->userId)) { return; } parent::handle(); $this->response = new ApiJsonResponse(); try { $json = json_decode($this->requestBody); $user = new User($this->userId); if ($user->getEmail() !== $json->email) { $user->setEmail($json->email); $user->Save(); } } catch (Throwable $e) { $this->response->setStatus($e->getCode() !== 0 ? $e->getCode() : ServerStatus::BAD_REQUEST); $this->response->setParameter('success', false); $this->response->setMessage($e->getMessage()); } } }