get('id') ?? Url::detectPortalId() ?? $this->config->get('defaultPortalId'); $basePath = $params->get('basePath') ?? $this->clientManager->getBasePath(); $requestWrapped = new RequestWrapper( ServerRequestCreatorFactory::create()->createServerRequestFromGlobals() ); $responseWrapped = new ResponseWrapper(new Response()); if ($requestWrapped->getMethod() !== 'GET') { throw new BadRequest("Only GET request is allowed."); } try { if (!$id) { throw new NotFound("Portal ID not detected."); } $application = new PortalApplication($id); } catch (Exception $e) { $this->processError($requestWrapped, $responseWrapped, $e); return; } $application->setClientBasePath($basePath); $application->run(PortalPortalClient::class); } private function processError(RequestWrapper $request, ResponseWrapper $response, Exception $exception): void { $this->errorOutput->processWithBodyPrinting($request, $response, $exception); (new ResponseEmitter())->emit($response->toPsr7()); } }