From 806d8e159cd943a76cb3b0d0c0df6f234198329e Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 14 Aug 2021 16:47:19 +0300 Subject: [PATCH] feat(endpoints): add Registry endpoints #565 --- src/flextype/core/Endpoints/Registry.php | 51 ++++++++++++++++++++++ src/flextype/flextype.php | 1 + src/flextype/routes/endpoints/registry.php | 27 ++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 src/flextype/core/Endpoints/Registry.php create mode 100644 src/flextype/routes/endpoints/registry.php diff --git a/src/flextype/core/Endpoints/Registry.php b/src/flextype/core/Endpoints/Registry.php new file mode 100644 index 00000000..db527924 --- /dev/null +++ b/src/flextype/core/Endpoints/Registry.php @@ -0,0 +1,51 @@ +getQueryParams(); + + // Validate Api Request + if ( + count($result = $this->validateApiRequest([ + 'request' => $request, + 'api' => 'registry', + 'params' => ['token', 'key'], + ])) > 0 + ) { + return $this->getApiResponse($response, $this->getStatusCodeMessage($result['http_status_code']), $result['http_status_code']); + } + + // Get registry data + $registryData = registry()->get($requestQueryParams['key'], $requestQueryParams['default'] ?? null); + + return $this->getApiResponse($response, ['key' => $requestQueryParams['key'], 'value' => $registryData], 200); + } +} diff --git a/src/flextype/flextype.php b/src/flextype/flextype.php index cc2b2129..c8855341 100644 --- a/src/flextype/flextype.php +++ b/src/flextype/flextype.php @@ -453,6 +453,7 @@ require_once ROOT_DIR . '/src/flextype/routes/endpoints/images.php'; require_once ROOT_DIR . '/src/flextype/routes/endpoints/content.php'; require_once ROOT_DIR . '/src/flextype/routes/endpoints/media.php'; require_once ROOT_DIR . '/src/flextype/routes/endpoints/tokens.php'; +require_once ROOT_DIR . '/src/flextype/routes/endpoints/registry.php'; // Enable lazy CORS diff --git a/src/flextype/routes/endpoints/registry.php b/src/flextype/routes/endpoints/registry.php new file mode 100644 index 00000000..ce4dbe2b --- /dev/null +++ b/src/flextype/routes/endpoints/registry.php @@ -0,0 +1,27 @@ +get('/api/registry', [Registry::class, 'get']); \ No newline at end of file