2022-03-19 00:00:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace brain\api\v1;
|
|
|
|
|
|
|
|
use brain\utility\Setup;
|
|
|
|
|
|
|
|
class InitAPI
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
}
|
2022-05-17 04:14:38 +02:00
|
|
|
|
2022-03-19 00:00:51 +01:00
|
|
|
public static function handleInitTasks($task, $request)
|
|
|
|
{
|
|
|
|
//check if a site config already exists. if it does, deny set up request
|
|
|
|
//restore to previous version of site while a config exists is only accessible
|
|
|
|
//through settings.
|
|
|
|
|
|
|
|
if (Setup::status()) {
|
2022-05-17 02:41:15 +02:00
|
|
|
$result = ['type' => 'blogInitFail', 'message' => 'Site already set up'];
|
2022-03-19 00:00:51 +01:00
|
|
|
} else {
|
|
|
|
switch ($task) {
|
2022-05-17 02:41:15 +02:00
|
|
|
case 'init':
|
2022-03-19 00:00:51 +01:00
|
|
|
$result = Setup::init($request);
|
|
|
|
break;
|
2022-05-17 02:41:15 +02:00
|
|
|
case 'restore':
|
2022-03-19 00:00:51 +01:00
|
|
|
$result = Setup::restore($request);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|