mirror of
https://github.com/flextype/flextype.git
synced 2025-08-09 06:36:52 +02:00
feat(core): use Atomastic Components #478
This commit is contained in:
@@ -82,7 +82,7 @@ flextype()->get('/api/entries', function (Request $request, Response $response)
|
||||
}
|
||||
|
||||
// Update calls counter
|
||||
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])));
|
||||
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
|
||||
@@ -185,7 +185,7 @@ flextype()->post('/api/entries', function (Request $request, Response $response)
|
||||
$response_code = $create_entry ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
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])));
|
||||
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
|
||||
|
@@ -393,7 +393,7 @@ flextype()->put('/api/files/copy', function (Request $request, Response $respons
|
||||
$response_code = $copy_file === true ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
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])));
|
||||
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
|
||||
@@ -563,7 +563,7 @@ flextype()->patch('/api/files/meta', function (Request $request, Response $respo
|
||||
|
||||
// Set files and access token file
|
||||
if (($files_token_file_data = flextype('yaml')->decode(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)))) {
|
||||
($access_token_file_data = flextype('yaml')->decode(filesystem()->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
|
||||
@@ -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(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 = flextype('yaml')->decode(filesystem()->file($files_token_file_path)->get())) &&
|
||||
($access_token_file_data = flextype('yaml')->decode(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
|
||||
@@ -802,7 +802,7 @@ flextype()->delete('/api/files/meta', function (Request $request, Response $resp
|
||||
$response_code = $delete_file_meta ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
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])));
|
||||
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
|
||||
|
@@ -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(flextype('filesytem')->file($folders_token_file_path)->get())) {
|
||||
if ($folders_token_file_data = flextype('yaml')->decode(filesystem()->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'])
|
||||
@@ -395,7 +395,7 @@ flextype()->put('/api/folders', function (Request $request, Response $response)
|
||||
$response_code = $rename_folder ? 200 : 404;
|
||||
|
||||
// Update calls counter
|
||||
flextype('filesytem')->file($folders_token_file_path)->put(flextype('yaml')->encode(array_replace_recursive($folders_token_file_data, ['calls' => $folders_token_file_data['calls'] + 1])));
|
||||
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
|
||||
|
@@ -63,7 +63,7 @@ flextype()->get('/api/images/{path:.+}', function (Request $request, Response $r
|
||||
}
|
||||
|
||||
// Update calls counter
|
||||
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])));
|
||||
filesystem()->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()->file(PATH['project'] . '/uploads/entries/' . $args['path'])->exists()) {
|
||||
return flextype('images')->getImageResponse($args['path'], $_GET);
|
||||
|
@@ -10,7 +10,7 @@ declare(strict_types=1);
|
||||
if (flextype('registry')->get('flextype.settings.entries.fields.published_at.enabled')) {
|
||||
flextype('emitter')->addListener('onEntryAfterInitialized', static function (): void {
|
||||
if (flextype('entries')->getStorage('fetch_single.data.published_at') === null) {
|
||||
flextype('entries')->setStorage('fetch_single.data.published_at', (int) flextype('filesytem')->file(flextype('entries')->getFileLocation(flextype('entries')->getStorage('fetch_single.id')))->lastModified());
|
||||
flextype('entries')->setStorage('fetch_single.data.published_at', (int) filesystem()->file(flextype('entries')->getFileLocation(flextype('entries')->getStorage('fetch_single.id')))->lastModified());
|
||||
} else {
|
||||
flextype('entries')->setStorage('fetch_single.data.published_at', (int) strtotime((string) flextype('entries')->getStorage('fetch_single.data.published_at')));
|
||||
}
|
||||
|
Reference in New Issue
Block a user