getPsrRequest()->getQueryParams(); if (empty($requestParams['testUri'])) { throw new InvalidArgumentException('Required `testUri` param is missing '); } $testPreviewRequest = new TestPreviewRequest( $requestParams['testUri'], new TestPreviewConfig([TestPreviewConfig::CHECK_INFORMATIONAL => true]) ); $response = $this->getTestPreviewerService()->createPreview($testPreviewRequest); $this->setNoCacheHeaders(); $this->setSuccessJsonResponse( [ 'success' => true, 'testData' => [], 'testContext' => [], 'testMap' => $response->getMap()->getMap(), 'presetMap' => $this->getTestPreviewerPresetsMapService()->getMap() ] ); } catch (Throwable $exception) { $message = $exception instanceof common_exception_UserReadableException ? $exception->getUserMessage() : $exception->getMessage(); $this->setErrorJsonResponse($message); } } public function configuration(): void { try { $this->setNoCacheHeaders(); $this->setSuccessJsonResponse( $this->getTestPreviewerConfigurationService()->getConfiguration() ); } catch (Throwable $exception) { $message = $exception instanceof common_exception_UserReadableException ? $exception->getUserMessage() : $exception->getMessage(); $this->setErrorJsonResponse($message); } } private function setNoCacheHeaders(): void { $this->getResponseFormatter() ->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate') ->addHeader('Pragma', 'no-cache') ->addHeader('Expires', '0'); } private function getTestPreviewerConfigurationService(): TestPreviewerConfigurationService { return $this->getServiceLocator()->get(TestPreviewerConfigurationService::class); } private function getTestPreviewerService(): TestPreviewerService { return $this->getServiceLocator()->get(TestPreviewerService::class); } private function getTestPreviewerPresetsMapService(): TestCategoryPresetMap { return $this->getPsrContainer()->get(TestCategoryPresetMap::class); } }