From 691245a2a07220b37abedbd59b43b958f69fc312 Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 16 Apr 2020 16:01:09 +0300 Subject: [PATCH] refactor(core): add new Images API instead of Delivery Images API --- src/flextype/bootstrap.php | 1 + src/flextype/config/settings.yaml | 6 +++--- .../endpoints/{delivery => images}/images.php | 16 ++++++++-------- 3 files changed, 12 insertions(+), 11 deletions(-) rename src/flextype/endpoints/{delivery => images}/images.php (84%) diff --git a/src/flextype/bootstrap.php b/src/flextype/bootstrap.php index 3afb179f..940fe1b7 100755 --- a/src/flextype/bootstrap.php +++ b/src/flextype/bootstrap.php @@ -132,6 +132,7 @@ include_once 'endpoints/delivery/images.php'; include_once 'endpoints/delivery/entries.php'; include_once 'endpoints/delivery/registry.php'; include_once 'endpoints/management/entries.php'; +include_once 'endpoints/images/images.php'; /** * Set internal encoding diff --git a/src/flextype/config/settings.yaml b/src/flextype/config/settings.yaml index 20150f7d..d3c08a35 100644 --- a/src/flextype/config/settings.yaml +++ b/src/flextype/config/settings.yaml @@ -190,9 +190,6 @@ image: # API's api: delivery: - images: - enabled: true - default_token: entries: enabled: true default_token: @@ -203,3 +200,6 @@ api: entries: enabled: true default_token: + images: + enabled: true + default_token: diff --git a/src/flextype/endpoints/delivery/images.php b/src/flextype/endpoints/images/images.php similarity index 84% rename from src/flextype/endpoints/delivery/images.php rename to src/flextype/endpoints/images/images.php index 0e6e9c55..3001442f 100644 --- a/src/flextype/endpoints/delivery/images.php +++ b/src/flextype/endpoints/images/images.php @@ -16,17 +16,17 @@ use function array_replace_recursive; use function header; /** - * Validate delivery images token + * Validate images token */ -function validate_delivery_images_token($token) : bool +function validate_images_token($token) : bool { - return Filesystem::has(PATH['site'] . '/tokens/delivery/images/' . $token . '/token.yaml'); + return Filesystem::has(PATH['site'] . '/tokens/images/' . $token . '/token.yaml'); } /** * Fetch image * - * endpoint: GET /api/delivery/images + * endpoint: GET /api/images * * Parameters: * path - [REQUIRED] - The file path with valid params for image manipulations. @@ -37,7 +37,7 @@ function validate_delivery_images_token($token) : bool * Returns: * Image file */ -$app->get('/api/delivery/images/{path:.+}', function (Request $request, Response $response, $args) use ($flextype) { +$app->get('/api/images/{path:.+}', function (Request $request, Response $response, $args) use ($flextype) { // Get Query Params $query = $request->getQueryParams(); @@ -45,11 +45,11 @@ $app->get('/api/delivery/images/{path:.+}', function (Request $request, Response // Set variables $token = $query['token']; - if ($flextype['registry']->get('flextype.settings.api.delivery.images.enabled')) { + if ($flextype['registry']->get('flextype.settings.api.images.enabled')) { // Validate delivery image token - if (validate_delivery_images_token($token)) { - $delivery_images_token_file_path = PATH['site'] . '/tokens/delivery/images/' . $token . '/token.yaml'; + if (validate_images_token($token)) { + $delivery_images_token_file_path = PATH['site'] . '/tokens/images/' . $token . '/token.yaml'; // Set delivery token file if ($delivery_images_token_file_data = $flextype['parser']->decode(Filesystem::read($delivery_images_token_file_path), 'yaml')) {