action update module add
This commit is contained in:
@ -172,6 +172,9 @@ class ModuleService
|
||||
// $out->out->r('Архив распакован', 'green');
|
||||
// } else {
|
||||
// $this->out->r('Message: Ошибка чтения архива', 'red');
|
||||
} else {
|
||||
$zip->close();
|
||||
throw new \Exception("unable to open zip archive");
|
||||
}
|
||||
|
||||
if (!file_exists($tmpModuleDirFull . "/app/manifest.json")) {
|
||||
@ -192,6 +195,7 @@ class ModuleService
|
||||
|
||||
// $this->out->r("Удаляем временные файлы", 'green');
|
||||
$fileHelper->recursiveRemoveDir($tmpModuleDirFull);
|
||||
var_dump($tmpModuleDirFull);
|
||||
|
||||
// $this->out->r("Модуль " . $manifest['name'] . " установлен", 'green');
|
||||
}
|
||||
@ -229,7 +233,50 @@ class ModuleService
|
||||
|
||||
// $this->out->r("Архив создан", 'green');
|
||||
$fileHelper->recursiveRemoveDir($tmpModuleDirFull);
|
||||
|
||||
// $this->out->r("Временная папка удалена", 'green');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function updateModule(string $path): void
|
||||
{
|
||||
$zip = new ZipArchive;
|
||||
$tmpModuleDir = md5(time());
|
||||
$res = $zip->open(ROOT_DIR . $path);
|
||||
if ($res === TRUE) {
|
||||
$tmpModuleDirFull = RESOURCES_DIR . '/tmp/ad/' . $tmpModuleDir . "/";
|
||||
$zip->extractTo($tmpModuleDirFull);
|
||||
$zip->close();
|
||||
// $out->out->r('Архив распакован', 'green');
|
||||
// } else {
|
||||
// $this->out->r('Message: Ошибка чтения архива', 'red');
|
||||
} else {
|
||||
$zip->close();
|
||||
throw new \Exception("unable to open zip archive");
|
||||
}
|
||||
|
||||
if (!file_exists($tmpModuleDirFull . "/app/manifest.json")) {
|
||||
throw new \Exception('manifest.json not found');
|
||||
}
|
||||
|
||||
$manifestJson = getConst(file_get_contents($tmpModuleDirFull . "/app/manifest.json"));
|
||||
$manifest = Manifest::getWithVars($manifestJson);
|
||||
// $this->out->r('manifest.json инициализирован', 'green');
|
||||
|
||||
$fileHelper = new Files();
|
||||
if (isset($manifest['kernel_module_path'])) {
|
||||
$fileHelper->copy_folder($tmpModuleDirFull . '/kernel', $manifest['kernel_module_path']);
|
||||
} else {
|
||||
$fileHelper->copy_folder($tmpModuleDirFull . '/kernel', KERNEL_APP_MODULES_DIR . '/' . $manifest['slug']);
|
||||
}
|
||||
|
||||
// $this->out->r("Удаляем временные файлы", 'green');
|
||||
$fileHelper->recursiveRemoveDir($tmpModuleDirFull);
|
||||
|
||||
// $this->out->r("Модуль " . $manifest['name'] . " установлен", 'green');
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user