From 6cf35d56381183f6c5df020df1ba5122369ecb8a Mon Sep 17 00:00:00 2001 From: stasbilay02 Date: Fri, 8 Nov 2024 14:47:59 +0300 Subject: [PATCH] install modulu from shop --- .../ModuleShopClientController.php | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php b/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php index abcdb6f..9456ce8 100644 --- a/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php +++ b/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php @@ -34,7 +34,7 @@ class ModuleShopClientController extends AdminController $per_page = 8; $token = $_ENV['MODULE_SHOP_TOKEN']; - $modules_info = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/module_shop/gb_slug', [ + $modules_info = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug', [ 'headers' => [ 'Authorization' => 'Bearer ' . $token, ] @@ -56,8 +56,8 @@ class ModuleShopClientController extends AdminController */ public function actionView(int $id): void { - $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.W10.POQZmGB7EZIayINtYhzu5r1rdgZhF9qPJpaQkl_g6pU'; - $module_info = $this->client->request('GET', 'http://igfs.loc/api/module_shop/' . $id, [ + $token = $_ENV['MODULE_SHOP_TOKEN']; + $module_info = $this->client->request('GET', $_ENV['MODULE_SHOP_URL'] . '/api/module_shop/' . $id, [ 'headers' => [ 'Authorization' => 'Bearer ' . $token, ] @@ -69,19 +69,38 @@ class ModuleShopClientController extends AdminController /** * @throws GuzzleException */ - public function actionInstall(): void + #[NoReturn] public function actionInstall(): void { $request = new Request(); - $id = $request->get("id"); - $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.W10.POQZmGB7EZIayINtYhzu5r1rdgZhF9qPJpaQkl_g6pU'; - $module_info = $this->client->request('GET', 'http://igfs.loc/api/module_shop/' . $id, [ + $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_info = json_decode($module_info->getBody()->getContents(), true); - Debug::dd($module_info['path_to_archive']); - $this->moduleService->installModule($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); +// Debug::dd($_ENV['MODULE_SHOP_URL'] . $module_info['path_to_archive']); +// $this->moduleService->installModule(RESOURCES_DIR . '/tmp/ms/some.igm'); +// $this->redirect('/admin/module_shop_client', 302); }