clientManager = $clientManager; $this->config = $config; $this->params = $params ?? (object) []; } public function run() : void { $id = $this->params->id ?? Url::detectPortalId() ?? $this->config->get('defaultPortalId'); $basePath = $this->params->basePath ?? $this->clientManager->getBasePath(); $requestWrapped = new RequestWrapper( ServerRequestCreatorFactory::create()->createServerRequestFromGlobals() ); $responseWrapped = new ResponseWrapper( new Response() ); if ($requestWrapped->getMethod() !== 'GET') { throw new Error("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); } protected function processError(RequestWrapper $request, ResponseWrapper $response, Exception $exception) { (new ApiErrorOutput($request))->process($response, $exception, true); (new ResponseEmitter())->emit($response->getResponse()); } }