From 04bd134e3e2bdc6a4694e1d9d9bd373ef97b2ae8 Mon Sep 17 00:00:00 2001 From: stasbilay02 Date: Mon, 23 Dec 2024 16:41:47 +0300 Subject: [PATCH] some --- .../controllers/ModuleShopClientController.php | 8 +++++--- .../services/ModuleShopClientService.php | 16 +++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php b/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php index 68a96f2..49be935 100644 --- a/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php +++ b/kernel/modules/module_shop_client/controllers/ModuleShopClientController.php @@ -10,14 +10,12 @@ use kernel\Flash; use kernel\helpers\Debug; use kernel\helpers\Files; use kernel\helpers\RESTClient; -use kernel\helpers\SMTP; -use kernel\Mailing; +use kernel\modules\module_shop_client\services\ModuleShopClientService; use kernel\Request; use kernel\services\AdminThemeService; use kernel\services\KernelService; use kernel\services\ModuleService; use kernel\services\ModuleShopService; -use kernel\services\TokenService; use PHPMailer\PHPMailer\Exception; class ModuleShopClientController extends AdminController @@ -26,6 +24,7 @@ class ModuleShopClientController extends AdminController protected Client $client; protected ModuleService $moduleService; protected KernelService $kernelService; + protected ModuleShopClientService $moduleShopClientService; protected function init(): void { @@ -35,6 +34,7 @@ class ModuleShopClientController extends AdminController $this->client = new Client(); $this->moduleService = new ModuleService(); $this->kernelService = new KernelService(); + $this->moduleShopClientService = new ModuleShopClientService(); } /** @@ -49,6 +49,8 @@ class ModuleShopClientController extends AdminController $filters = $request->get(); $per_page = 8; + +// $this->moduleShopClientService->getModulesInfo($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug') $modules = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug'); $modules = json_decode($modules->getBody()->getContents(), true); if ($filters) { diff --git a/kernel/modules/module_shop_client/services/ModuleShopClientService.php b/kernel/modules/module_shop_client/services/ModuleShopClientService.php index 9fbb496..b33f37e 100644 --- a/kernel/modules/module_shop_client/services/ModuleShopClientService.php +++ b/kernel/modules/module_shop_client/services/ModuleShopClientService.php @@ -6,11 +6,17 @@ use kernel\helpers\RESTClient; class ModuleShopClientService { - public function getModulesInfo(string $url) + public function getModulesInfo(string $url, int $perPage, int $pageNumber): \Psr\Http\Message\ResponseInterface { -// $modules_info = RESTClient::request($url); -// $modules_info = json_decode($modules_info->getBody()->getContents(), true); -// $module_count = count($modules_info); -// $modules_info = array_slice($modules_info, $per_page * ($page_number - 1), $per_page); + $modules_info = RESTClient::request($url); + $modules_info = json_decode($modules_info->getBody()->getContents(), true); + return array_slice($modules_info, $perPage * ($pageNumber - 1), $perPage); + } + + public function getModulesInfoWithFilters(string $url, int $perPage, int $pageNumber): \Psr\Http\Message\ResponseInterface + { + $modules_info = RESTClient::request($url); + $modules_info = json_decode($modules_info->getBody()->getContents(), true); + return array_slice($modules_info, $perPage * ($pageNumber - 1), $perPage); } } \ No newline at end of file