MicroFrameWork/kernel/console/controllers/ModuleController.php

81 lines
2.2 KiB
PHP
Raw Normal View History

2024-10-08 12:16:41 +03:00
<?php
namespace kernel\console\controllers;
use kernel\console\ConsoleController;
2024-10-08 17:06:14 +03:00
use kernel\helpers\Debug;
2024-10-08 12:16:41 +03:00
use kernel\helpers\Files;
use kernel\helpers\Manifest;
use kernel\models\Option;
use ZipArchive;
use kernel\services\ModuleService;
class ModuleController extends ConsoleController
{
/**
* @throws \Exception
*/
public function actionInstallModule(): void
{
if (!isset($this->argv['path'])) {
throw new \Exception('Missing module path "--path" specified');
}
if (file_exists(ROOT_DIR . $this->argv['path'])) {
$moduleService = new ModuleService();
$moduleService->installModule($this->argv['path']);
2024-10-08 12:16:41 +03:00
} else {
$this->out->r("Модуль не найден", 'red');
2024-10-08 12:16:41 +03:00
}
}
/**
* @throws \Exception
*/
public function actionUninstallModule(): void
{
if (!isset($this->argv['path'])) {
throw new \Exception('Missing module path "--path" specified');
}
if (file_exists(ROOT_DIR . $this->argv['path'])) {
$moduleService = new ModuleService();
$moduleService->uninstallModule($this->argv['path']);
2024-10-08 12:16:41 +03:00
} else {
$this->out->r("Модуль не найден", 'red');
}
}
/**
* @throws \Exception
*/
2024-10-08 17:06:14 +03:00
public function actionPackModule(): void
{
if (!isset($this->argv['path'])) {
throw new \Exception('Missing module path "--path" specified');
}
if (file_exists(ROOT_DIR . $this->argv['path'])) {
$moduleService = new ModuleService();
$moduleService->packModule($this->argv['path']);
} else {
$this->out->r("Модуль не найден", 'red');
2024-10-08 17:06:14 +03:00
}
}
2024-10-10 11:19:51 +03:00
/**
* @throws \Exception
*/
public function actionUpdateModule(): void
{
if (!isset($this->argv['path'])) {
throw new \Exception('Missing module path "--path" specified');
}
if (file_exists(ROOT_DIR . $this->argv['path'])) {
$moduleService = new ModuleService();
$moduleService->updateModule($this->argv['path']);
}
}
2024-10-08 12:16:41 +03:00
}