mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-01 19:06:16 +01:00
create adhoc snapshot
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user