geoproject-app/public/site/plugins/map-editor/routes/image/check-flag.php

40 lines
1,002 B
PHP
Raw Normal View History

<?php
/**
* GET check if regeneration flag exists
*/
return [
'pattern' => 'map-editor/pages/(:all)/check-regenerate-flag',
'method' => 'GET',
'auth' => false,
'action' => function (string $pageId) {
try {
$page = kirby()->page($pageId);
if (!$page) {
return [
'status' => 'error',
'message' => 'Page not found',
'code' => 404
];
}
$markerFile = $page->root() . '/.regenerate-map-image';
$needsRegeneration = file_exists($markerFile);
return [
'status' => 'success',
'data' => [
'needsRegeneration' => $needsRegeneration
]
];
} catch (Exception $e) {
return [
'status' => 'error',
'message' => $e->getMessage(),
'code' => 500
];
}
}
];