makeJSONResponse(fn () => $this->appSettings->getAll($this->userId)); } #[NoAdminRequired] public function set(string $folderVariant, string $buttonVariant): JSONResponse { $this->appSettings->set($this->userId, $folderVariant, $buttonVariant); return $this->makeJSONResponse(fn () => $this->appSettings->getAll($this->userId)); } #[AuthorizedAdminSetting] public function setGlobal(string $folderVariant, string $buttonVariant): JSONResponse { $this->appSettings->setGlobal($folderVariant, $buttonVariant); return $this->makeJSONResponse(fn () => $this->appSettings->getGlobal()); } #[NoCSRFRequired] public function getGlobal(): JSONResponse { return $this->makeJSONResponse(fn () => $this->appSettings->getGlobal()); } protected function makeJSONResponse(Closure $closure): JSONResponse { try { return new JSONResponse($closure(), HTTP::STATUS_OK); } catch (Exception $e) { return new JSONResponse(['message' => $e->getMessage()], HTTP::INTERNAL_SERVER_ERROR); } } }