1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-26 14:34:31 +02:00

refactor(core): add new Images API instead of Delivery Images API

This commit is contained in:
Awilum
2020-04-16 16:01:09 +03:00
parent eae97b1fd0
commit 691245a2a0
3 changed files with 12 additions and 11 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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')) {