create adhoc snapshot

This commit is contained in:
Andy Miller
2025-10-18 18:41:39 -06:00
parent c4fb1f7fd8
commit 419fcc3f13
6 changed files with 379 additions and 37 deletions

View File

@@ -981,6 +981,45 @@ class AdminController extends AdminBaseController
return true;
}
/**
* Create a manual safe-upgrade snapshot via Tools.
*
* Route: POST /tools/restore-grav?task:safeUpgradeSnapshot
*
* @return bool
*/
public function taskSafeUpgradeSnapshot()
{
if (!$this->authorizeTask('install grav', ['admin.super'])) {
$this->sendJsonResponse([
'status' => 'error',
'message' => $this->admin::translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK')
]);
return false;
}
$post = $this->getPost($_POST ?? []);
$label = isset($post['label']) ? (string)$post['label'] : null;
$manager = $this->getSafeUpgradeManager();
$result = $manager->queueSnapshot($label);
$status = $result['status'] ?? 'error';
$response = [
'status' => $status === 'error' ? 'error' : 'success',
'data' => $result,
];
if (!empty($result['message'])) {
$response['message'] = $result['message'];
}
$this->sendJsonResponse($response);
return true;
}
/**
* Delete one or more safe-upgrade snapshots via Tools.
*