flash, middleware

This commit is contained in:
2024-10-17 14:55:00 +03:00
parent c3c377a4e2
commit 4355651695
22 changed files with 226 additions and 75 deletions

View File

@ -5,9 +5,17 @@ namespace kernel\console\controllers;
use kernel\console\ConsoleController;
use kernel\helpers\Files;
use kernel\services\KernelService;
use ZipArchive;
class KernelController extends ConsoleController
{
protected Files $files;
public function __construct()
{
parent::__construct();
$this->files = new Files();
}
/**
* @throws \Exception
@ -34,4 +42,40 @@ class KernelController extends ConsoleController
}
}
/**
* @throws \Exception
*/
public function actionUpdateKernel()
{
if (!isset($this->argv['path'])) {
throw new \Exception('Missing kernel path "--path" specified');
}
$path = $this->argv['path'];
if (file_exists(ROOT_DIR . $path)) {
$zip = new ZipArchive;
$tmpKernelDir = md5(time());
$res = $zip->open(ROOT_DIR . $path);
if ($res === TRUE) {
$tmpKernelDirFull = RESOURCES_DIR . '/tmp/kernel/' . $tmpKernelDir . "/";
$zip->extractTo($tmpKernelDirFull);
$zip->close();
$this->files->copy_folder($tmpKernelDirFull , ROOT_DIR . "/kernel");
$this->files->recursiveRemoveDir($tmpKernelDirFull);
$this->out->r('Ядро обновлено.', 'green');
} else {
$this->out->r('unable to open zip archive', 'red');
return false;
}
} else {
$this->out->r("Модуль не найден", 'red');
}
}
public function test()
{
}
}