mirror of
https://github.com/flextype/flextype.git
synced 2025-08-10 15:14:20 +02:00
feat(endpoints): use Atomastic Components for endpoints #478
This commit is contained in:
@@ -14,5 +14,5 @@ namespace Flextype;
|
||||
*/
|
||||
function validate_access_token($token) : bool
|
||||
{
|
||||
return flextype('filesystem')->exists(PATH['project'] . '/tokens/access/' . $token . '/token.yaml');
|
||||
return flextype('filesystem')->file(PATH['project'] . '/tokens/access/' . $token . '/token.yaml')->exists();
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ use function is_array;
|
||||
*/
|
||||
function validate_entries_token($token) : bool
|
||||
{
|
||||
return flextype('filesystem')->exists(PATH['project'] . '/tokens/entries/' . $token . '/token.yaml');
|
||||
return flextype('filesystem')->file(PATH['project'] . '/tokens/entries/' . $token . '/token.yaml')->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ flextype()->get('/api/entries', function (Request $request, Response $response)
|
||||
$entries_token_file_path = PATH['project'] . '/tokens/entries/' . $token . '/token.yaml';
|
||||
|
||||
// Set entries token file
|
||||
if ($entries_token_file_data = flextype('yaml')->decode(Filesystem::read($entries_token_file_path))) {
|
||||
if ($entries_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($entries_token_file_path)->get())) {
|
||||
if ($entries_token_file_data['state'] === 'disabled' ||
|
||||
($entries_token_file_data['limit_calls'] !== 0 && $entries_token_file_data['calls'] >= $entries_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -82,7 +82,7 @@ flextype()->get('/api/entries', function (Request $request, Response $response)
|
||||
}
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($entries_token_file_path, flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
flextype('filesytem')->file($entries_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -154,8 +154,8 @@ flextype()->post('/api/entries', function (Request $request, Response $response)
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set entries and access token file
|
||||
if (($entries_token_file_data = flextype('yaml')->decode(Filesystem::read($entries_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($entries_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($entries_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($entries_token_file_data['state'] === 'disabled' ||
|
||||
($entries_token_file_data['limit_calls'] !== 0 && $entries_token_file_data['calls'] >= $entries_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -185,7 +185,7 @@ flextype()->post('/api/entries', function (Request $request, Response $response)
|
||||
$response_code = $create_entry ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($entries_token_file_path, flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
flextype('filesytem')->file($entries_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -258,8 +258,8 @@ flextype()->patch('/api/entries', function (Request $request, Response $response
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set entries and access token file
|
||||
if (($entries_token_file_data = flextype('yaml')->decode(Filesystem::read($entries_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($entries_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($entries_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($entries_token_file_data['state'] === 'disabled' ||
|
||||
($entries_token_file_data['limit_calls'] !== 0 && $entries_token_file_data['calls'] >= $entries_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -289,7 +289,7 @@ flextype()->patch('/api/entries', function (Request $request, Response $response
|
||||
$response_code = $update_entry ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($entries_token_file_path, flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($entries_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -362,8 +362,8 @@ flextype()->put('/api/entries', function (Request $request, Response $response)
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set entries and access token file
|
||||
if (($entries_token_file_data = flextype('yaml')->decode(Filesystem::read($entries_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($entries_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($entries_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($entries_token_file_data['state'] === 'disabled' ||
|
||||
($entries_token_file_data['limit_calls'] !== 0 && $entries_token_file_data['calls'] >= $entries_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -394,7 +394,7 @@ flextype()->put('/api/entries', function (Request $request, Response $response)
|
||||
$response_code = $rename_entry ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($entries_token_file_path, flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($entries_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -467,8 +467,8 @@ flextype()->put('/api/entries/copy', function (Request $request, Response $respo
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set entries and access token file
|
||||
if (($entries_token_file_data = flextype('yaml')->decode(Filesystem::read($entries_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($entries_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($entries_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($entries_token_file_data['state'] === 'disabled' ||
|
||||
($entries_token_file_data['limit_calls'] !== 0 && $entries_token_file_data['calls'] >= $entries_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -499,7 +499,7 @@ flextype()->put('/api/entries/copy', function (Request $request, Response $respo
|
||||
$response_code = $copy_entry === null ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($entries_token_file_path, flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($entries_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -570,8 +570,8 @@ flextype()->delete('/api/entries', function (Request $request, Response $respons
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set entries and access token file
|
||||
if (($entries_token_file_data = flextype('yaml')->decode(Filesystem::read($entries_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($entries_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($entries_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($entries_token_file_data['state'] === 'disabled' ||
|
||||
($entries_token_file_data['limit_calls'] !== 0 && $entries_token_file_data['calls'] >= $entries_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -595,7 +595,7 @@ flextype()->delete('/api/entries', function (Request $request, Response $respons
|
||||
$response_code = $delete_entry ? 204 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($entries_token_file_path, flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($entries_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($entries_token_file_data, ['calls' => $entries_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
|
@@ -21,7 +21,7 @@ use function is_dir;
|
||||
*/
|
||||
function validate_files_token($token) : bool
|
||||
{
|
||||
return flextype('filesystem')->exists(PATH['project'] . '/tokens/files/' . $token . '/token.yaml');
|
||||
return flextype('filesystem')->file(PATH['project'] . '/tokens/files/' . $token . '/token.yaml')->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ flextype()->get('/api/files', function (Request $request, Response $response) us
|
||||
$files_token_file_path = PATH['project'] . '/tokens/files/' . $token . '/token.yaml';
|
||||
|
||||
// Set delivery token file
|
||||
if ($files_token_file_data = flextype('yaml')->decode(Filesystem::read($files_token_file_path))) {
|
||||
if ($files_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($files_token_file_path)->get())) {
|
||||
if ($files_token_file_data['state'] === 'disabled' ||
|
||||
($files_token_file_data['limit_calls'] !== 0 && $files_token_file_data['calls'] >= $files_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -83,7 +83,7 @@ flextype()->get('/api/files', function (Request $request, Response $response) us
|
||||
$response_code = count($response_data['data']) > 0 ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($files_token_file_path, flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($files_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -155,8 +155,8 @@ flextype()->post('/api/files', function (Request $request, Response $response) u
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set files and access token file
|
||||
if (($files_token_file_data = flextype('yaml')->decode(Filesystem::read($files_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($files_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($files_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($files_token_file_data['state'] === 'disabled' ||
|
||||
($files_token_file_data['limit_calls'] !== 0 && $files_token_file_data['calls'] >= $files_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -183,10 +183,10 @@ flextype()->post('/api/files', function (Request $request, Response $response) u
|
||||
}
|
||||
|
||||
// Set response code
|
||||
$response_code = Filesystem::has($create_file) ? 200 : 404;
|
||||
$response_code = flextype('filesystem')->file($create_file)->exists() ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($files_token_file_path, flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($files_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -259,8 +259,8 @@ flextype()->put('/api/files', function (Request $request, Response $response) us
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set files and access token file
|
||||
if (($files_token_file_data = flextype('yaml')->decode(Filesystem::read($files_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($files_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($files_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($files_token_file_data['state'] === 'disabled' ||
|
||||
($files_token_file_data['limit_calls'] !== 0 && $files_token_file_data['calls'] >= $files_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -290,7 +290,7 @@ flextype()->put('/api/files', function (Request $request, Response $response) us
|
||||
$response_code = $rename_file === true ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($files_token_file_path, flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($files_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -362,8 +362,8 @@ flextype()->put('/api/files/copy', function (Request $request, Response $respons
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set files and access token file
|
||||
if (($files_token_file_data = flextype('yaml')->decode(Filesystem::read($files_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($files_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($files_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($files_token_file_data['state'] === 'disabled' ||
|
||||
($files_token_file_data['limit_calls'] !== 0 && $files_token_file_data['calls'] >= $files_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -393,7 +393,7 @@ flextype()->put('/api/files/copy', function (Request $request, Response $respons
|
||||
$response_code = $copy_file === true ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($files_token_file_path, flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
flextype('filesytem')->file($files_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -463,8 +463,8 @@ flextype()->delete('/api/files', function (Request $request, Response $response)
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set files and access token file
|
||||
if (($files_token_file_data = flextype('yaml')->decode(Filesystem::read($files_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($files_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($files_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($files_token_file_data['state'] === 'disabled' ||
|
||||
($files_token_file_data['limit_calls'] !== 0 && $files_token_file_data['calls'] >= $files_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -488,7 +488,7 @@ flextype()->delete('/api/files', function (Request $request, Response $response)
|
||||
$response_code = $delete_file ? 204 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($files_token_file_path, flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($files_token_file_path)->get(flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -562,8 +562,8 @@ flextype()->patch('/api/files/meta', function (Request $request, Response $respo
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set files and access token file
|
||||
if (($files_token_file_data = flextype('yaml')->decode(Filesystem::read($files_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($files_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($files_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesytem')->file($access_token_file_path)->get($access_token_file_path)))) {
|
||||
if ($files_token_file_data['state'] === 'disabled' ||
|
||||
($files_token_file_data['limit_calls'] !== 0 && $files_token_file_data['calls'] >= $files_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -593,7 +593,7 @@ flextype()->patch('/api/files/meta', function (Request $request, Response $respo
|
||||
$response_code = $update_file_meta ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($files_token_file_path, flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($files_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -667,8 +667,8 @@ flextype()->post('/api/files/meta', function (Request $request, Response $respon
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set files and access token file
|
||||
if (($files_token_file_data = flextype('yaml')->decode(Filesystem::read($files_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($files_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($files_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($files_token_file_data['state'] === 'disabled' ||
|
||||
($files_token_file_data['limit_calls'] !== 0 && $files_token_file_data['calls'] >= $files_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -698,7 +698,7 @@ flextype()->post('/api/files/meta', function (Request $request, Response $respon
|
||||
$response_code = $add_file_meta ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($files_token_file_path, flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($files_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -771,8 +771,8 @@ flextype()->delete('/api/files/meta', function (Request $request, Response $resp
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set files and access token file
|
||||
if (($files_token_file_data = flextype('yaml')->decode(Filesystem::read($files_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($files_token_file_data = flextype('yaml')->decode(flextype('filesytem')->file($files_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesytem')->file($access_token_file_path)->get()))) {
|
||||
if ($files_token_file_data['state'] === 'disabled' ||
|
||||
($files_token_file_data['limit_calls'] !== 0 && $files_token_file_data['calls'] >= $files_token_file_data['limit_calls'])) {
|
||||
return $response
|
||||
@@ -802,7 +802,7 @@ flextype()->delete('/api/files/meta', function (Request $request, Response $resp
|
||||
$response_code = $delete_file_meta ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($files_token_file_path, flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
flextype('filesytem')->file($files_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($files_token_file_data, ['calls' => $files_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
|
@@ -19,7 +19,7 @@ use function count;
|
||||
*/
|
||||
function validate_folders_token($token) : bool
|
||||
{
|
||||
return flextype('filesystem')->exists(PATH['project'] . '/tokens/folders/' . $token . '/token.yaml');
|
||||
return flextype('filesystem')->file(PATH['project'] . '/tokens/folders/' . $token . '/token.yaml')->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ flextype()->get('/api/folders', function (Request $request, Response $response)
|
||||
$folders_token_file_path = PATH['project'] . '/tokens/folders/' . $token . '/token.yaml';
|
||||
|
||||
// Set delivery token file
|
||||
if ($folders_token_file_data = flextype('yaml')->decode(Filesystem::read($folders_token_file_path))) {
|
||||
if ($folders_token_file_data = flextype('yaml')->decode(flextype('filesytem')->file($folders_token_file_path)->get())) {
|
||||
if ($folders_token_file_data['state'] === 'disabled' ||
|
||||
($folders_token_file_data['limit_calls'] !== 0 && $folders_token_file_data['calls'] >= $folders_token_file_data['limit_calls'])) {
|
||||
return $response->withStatus($api_errors['0501']['http_status_code'])
|
||||
@@ -91,7 +91,7 @@ flextype()->get('/api/folders', function (Request $request, Response $response)
|
||||
$response_code = count($response_data['data']) > 0 ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($folders_token_file_path, flextype('yaml')->encode(array_replace_recursive($folders_token_file_data, ['calls' => $folders_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($folders_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($folders_token_file_data, ['calls' => $folders_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -162,8 +162,8 @@ flextype()->post('/api/folders', function (Request $request, Response $response)
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set files and access token file
|
||||
if (($folders_token_file_data = flextype('yaml')->decode(Filesystem::read($folders_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($folders_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($folders_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($folders_token_file_data['state'] === 'disabled' ||
|
||||
($folders_token_file_data['limit_calls'] !== 0 && $folders_token_file_data['calls'] >= $folders_token_file_data['limit_calls'])) {
|
||||
return $response->withStatus($api_errors['0501']['http_status_code'])
|
||||
@@ -191,21 +191,21 @@ flextype()->post('/api/folders', function (Request $request, Response $response)
|
||||
$response_code = $create_folder ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($folders_token_file_path, flextype('yaml')->encode(array_replace_recursive($folders_token_file_data, ['calls' => $folders_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($folders_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($folders_token_file_data, ['calls' => $folders_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
return $response
|
||||
->withStatus($api_errors['0602']['http_status_code'])
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('json')->encode($api_errors['0602']));
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('json')->encode($api_errors['0602']));
|
||||
}
|
||||
|
||||
// Return response
|
||||
return $response
|
||||
->withStatus($response_code)
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('json')->encode($response_data));
|
||||
->withHeader('Content-Type', 'application/json;charset=' . flextype('registry')->get('flextype.settings.charset'))
|
||||
->write(flextype('json')->encode($response_data));
|
||||
}
|
||||
|
||||
return $response
|
||||
@@ -263,8 +263,8 @@ flextype()->put('/api/folders/copy', function (Request $request, Response $respo
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set files and access token file
|
||||
if (($folders_token_file_data = flextype('yaml')->decode(Filesystem::read($folders_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($folders_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($folders_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($folders_token_file_data['state'] === 'disabled' ||
|
||||
($folders_token_file_data['limit_calls'] !== 0 && $folders_token_file_data['calls'] >= $folders_token_file_data['limit_calls'])) {
|
||||
return $response->withStatus($api_errors['0601']['http_status_code'])
|
||||
@@ -294,7 +294,7 @@ flextype()->put('/api/folders/copy', function (Request $request, Response $respo
|
||||
$response_code = $copy_folder ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($folders_token_file_path, flextype('yaml')->encode(array_replace_recursive($folders_token_file_data, ['calls' => $folders_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($folders_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($folders_token_file_data, ['calls' => $folders_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -366,8 +366,8 @@ flextype()->put('/api/folders', function (Request $request, Response $response)
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set files and access token file
|
||||
if (($folders_token_file_data = flextype('yaml')->decode(Filesystem::read($folders_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($folders_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($folders_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextpye('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($folders_token_file_data['state'] === 'disabled' ||
|
||||
($folders_token_file_data['limit_calls'] !== 0 && $folders_token_file_data['calls'] >= $folders_token_file_data['limit_calls'])) {
|
||||
return $response->withStatus($api_errors['0501']['http_status_code'])
|
||||
@@ -395,7 +395,7 @@ flextype()->put('/api/folders', function (Request $request, Response $response)
|
||||
$response_code = $rename_folder ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($folders_token_file_path, flextype('yaml')->encode(array_replace_recursive($folders_token_file_data, ['calls' => $folders_token_file_data['calls'] + 1])));
|
||||
flextype('flextype')->file($folders_token_file_path)->put(lextype('yaml')->encode(array_replace_recursive($folders_token_file_data, ['calls' => $folders_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
@@ -465,8 +465,8 @@ flextype()->delete('/api/folders', function (Request $request, Response $respons
|
||||
$access_token_file_path = PATH['project'] . '/tokens/access/' . $access_token . '/token.yaml';
|
||||
|
||||
// Set files and access token file
|
||||
if (($folders_token_file_data = flextype('yaml')->decode(Filesystem::read($folders_token_file_path))) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(Filesystem::read($access_token_file_path)))) {
|
||||
if (($folders_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($folders_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($access_token_file_path)->get()))) {
|
||||
if ($folders_token_file_data['state'] === 'disabled' ||
|
||||
($folders_token_file_data['limit_calls'] !== 0 && $folders_token_file_data['calls'] >= $folders_token_file_data['limit_calls'])) {
|
||||
return $response->withStatus($api_errors['0501']['http_status_code'])
|
||||
@@ -488,7 +488,7 @@ flextype()->delete('/api/folders', function (Request $request, Response $respons
|
||||
$response_code = $delete_folder ? 204 : 404;
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($folders_token_file_path, flextype('yaml')->encode(array_replace_recursive($folders_token_file_data, ['calls' => $folders_token_file_data['calls'] + 1])));
|
||||
flextype('filesystem')->file($folders_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($folders_token_file_data, ['calls' => $folders_token_file_data['calls'] + 1])));
|
||||
|
||||
if ($response_code === 404) {
|
||||
// Return response
|
||||
|
@@ -18,7 +18,7 @@ use function array_replace_recursive;
|
||||
*/
|
||||
function validate_images_token($token) : bool
|
||||
{
|
||||
return flextype('filesystem')->exists(PATH['project'] . '/tokens/images/' . $token . '/token.yaml');
|
||||
return flextype('filesystem')->file(PATH['project'] . '/tokens/images/' . $token . '/token.yaml')->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ flextype()->get('/api/images/{path:.+}', function (Request $request, Response $r
|
||||
$delivery_images_token_file_path = PATH['project'] . '/tokens/images/' . $token . '/token.yaml';
|
||||
|
||||
// Set delivery token file
|
||||
if ($delivery_images_token_file_data = flextype('yaml')->decode(Filesystem::read($delivery_images_token_file_path))) {
|
||||
if ($delivery_images_token_file_data = flextype('yaml')->decode(flextype('filesystem')->file($delivery_images_token_file_path)->get())) {
|
||||
if ($delivery_images_token_file_data['state'] === 'disabled' ||
|
||||
($delivery_images_token_file_data['limit_calls'] !== 0 && $delivery_images_token_file_data['calls'] >= $delivery_images_token_file_data['limit_calls'])) {
|
||||
return $response->withStatus($api_errors['0003']['http_status_code'])
|
||||
@@ -63,9 +63,9 @@ flextype()->get('/api/images/{path:.+}', function (Request $request, Response $r
|
||||
}
|
||||
|
||||
// Update calls counter
|
||||
Filesystem::write($delivery_images_token_file_path, flextype('yaml')->encode(array_replace_recursive($delivery_images_token_file_data, ['calls' => $delivery_images_token_file_data['calls'] + 1])));
|
||||
flextype('filesytem')->file($delivery_images_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($delivery_images_token_file_data, ['calls' => $delivery_images_token_file_data['calls'] + 1])));
|
||||
|
||||
if (Filesystem::has(PATH['project'] . '/uploads/entries/' . $args['path'])) {
|
||||
if (flextype('filesystem')->file(PATH['project'] . '/uploads/entries/' . $args['path'])->exists()) {
|
||||
return flextype('images')->getImageResponse($args['path'], $_GET);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user