67 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace kernel\console\controllers;
 | |
| 
 | |
| use kernel\console\ConsoleController;
 | |
| use kernel\helpers\Debug;
 | |
| 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']);
 | |
|         } else {
 | |
|             $this->out->r("Модуль не найден", 'red');
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @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']);
 | |
|         } else {
 | |
|             $this->out->r("Модуль не найден", 'red');
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @throws \Exception
 | |
|      */
 | |
|     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');
 | |
|         }
 | |
|     }
 | |
| 
 | |
| } |