From 44c94689c60b5aa2b1f3546f6ad6d9b72c88678d Mon Sep 17 00:00:00 2001 From: Kavalar Date: Fri, 8 Nov 2024 16:19:11 +0300 Subject: [PATCH] some fix --- app/modules/tag/TagModule.php | 38 --------------- app/modules/tag/controllers/TagController.php | 8 ---- app/modules/tag/manifest.json | 12 ----- app/modules/tag/routs/tag.php | 2 - kernel/helpers/Files.php | 8 +++- .../ModuleShopClientController.php | 48 ++++++++++--------- kernel/services/ModuleService.php | 1 - 7 files changed, 33 insertions(+), 84 deletions(-) delete mode 100644 app/modules/tag/TagModule.php delete mode 100644 app/modules/tag/controllers/TagController.php delete mode 100644 app/modules/tag/manifest.json delete mode 100644 app/modules/tag/routs/tag.php diff --git a/app/modules/tag/TagModule.php b/app/modules/tag/TagModule.php deleted file mode 100644 index b2f0ffd..0000000 --- a/app/modules/tag/TagModule.php +++ /dev/null @@ -1,38 +0,0 @@ -menuService = new MenuService(); - $this->migrationService = new MigrationService(); - } - - /** - * @throws \Exception - */ - public function init(): void - { - $this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations"); - - $this->menuService->createItem([ - "label" => "Тэги", - "url" => "/admin/tag", - "slug" => "tag", - ]); - } - - public function deactivate(): void - { - $this->menuService->removeItemBySlug("tag"); - } -} \ No newline at end of file diff --git a/app/modules/tag/controllers/TagController.php b/app/modules/tag/controllers/TagController.php deleted file mode 100644 index 4598872..0000000 --- a/app/modules/tag/controllers/TagController.php +++ /dev/null @@ -1,8 +0,0 @@ -close(); } + public static function uploadByUrl(string $url, string $uploadDir = RESOURCES_DIR . "/upload"): void + { + $file_name = basename($url); + file_put_contents($uploadDir . '/' . $file_name, file_get_contents($url)); + } + private function recursiveAddFile(ZipArchive $zip, string $dir, string $folder = ''): void { $includes = new FilesystemIterator($dir); diff --git a/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php b/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php index 9456ce8..6d9e0ef 100644 --- a/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php +++ b/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php @@ -7,6 +7,7 @@ use GuzzleHttp\Exception\GuzzleException; use JetBrains\PhpStorm\NoReturn; use kernel\AdminController; use kernel\helpers\Debug; +use kernel\helpers\Files; use kernel\modules\module_shop_client\services\ModuleShopClientService; use kernel\Request; use kernel\services\ModuleService; @@ -71,37 +72,40 @@ class ModuleShopClientController extends AdminController */ #[NoReturn] public function actionInstall(): void { - $request = new Request(); - $id = $request->get('id'); - $token = $_ENV['MODULE_SHOP_TOKEN']; - Debug::prn(123); - $module = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/api/module_shop/install/' . $id, [ - 'headers' => [ - 'Authorization' => 'Bearer ' . $token, - 'Accept' => 'application/itguild', - 'sink' => RESOURCES_DIR . '/tmp/ms/some.itguild' - ] - ]); - - $module = json_decode($module->getBody()->getContents(), true); -// Debug::dd(123); - $this->moduleService->installModule(RESOURCES_DIR . '/tmp/ms/some.igm'); - $this->redirect('/admin/module_shop_client', 302); - - // $request = new Request(); -// $id = $request->get("id"); +// $id = $request->get('id'); // $token = $_ENV['MODULE_SHOP_TOKEN']; -// $module_info = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/api/module_shop/' . $id, [ +// Debug::prn(123); +// $module = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/api/module_shop/install/' . $id, [ // 'headers' => [ // 'Authorization' => 'Bearer ' . $token, +// 'Accept' => 'application/itguild', +// 'sink' => RESOURCES_DIR . '/tmp/ms/some.itguild' // ] // ]); -// $module_info = json_decode($module_info->getBody()->getContents(), true); -// Debug::dd($_ENV['MODULE_SHOP_URL'] . $module_info['path_to_archive']); +// +// $module = json_decode($module->getBody()->getContents(), true); +//// Debug::dd(123); // $this->moduleService->installModule(RESOURCES_DIR . '/tmp/ms/some.igm'); // $this->redirect('/admin/module_shop_client', 302); + + $request = new Request(); + $id = $request->get("id"); + $token = $_ENV['MODULE_SHOP_TOKEN']; + $module_info = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/api/module_shop/' . $id, [ + 'headers' => [ + 'Authorization' => 'Bearer ' . $token, + ] + ]); + $module_info = json_decode($module_info->getBody()->getContents(), true); + Files::uploadByUrl($_ENV['MODULE_SHOP_URL'] . $module_info['path_to_archive'], RESOURCES_DIR . "/tmp/modules"); + $this->moduleService->installModule('/resources/tmp/modules/' . basename($module_info['path_to_archive'])); +// Debug::prn($this->moduleService->getErrors()); +// Debug::dd(RESOURCES_DIR . '/tmp/modules/' . basename($module_info['path_to_archive'])); + $this->moduleService->installModule(RESOURCES_DIR . '/tmp/ms/some.igm'); + $this->redirect('/admin/module_shop_client', 302); + } #[NoReturn] public function actionDelete(): void diff --git a/kernel/services/ModuleService.php b/kernel/services/ModuleService.php index 1cd6e73..d886a05 100644 --- a/kernel/services/ModuleService.php +++ b/kernel/services/ModuleService.php @@ -421,7 +421,6 @@ class ModuleService $dirs[] = getConst($p); } } - foreach ($dirs as $dir){ foreach (new DirectoryIterator($dir) as $fileInfo) { if($fileInfo->isDot()) continue;