flash, middleware
This commit is contained in:
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user