This commit is contained in:
Билай Станислав 2024-12-23 15:47:03 +03:00
parent de690dfd39
commit c23b84bcea
4 changed files with 40 additions and 5 deletions

View File

@ -42,13 +42,31 @@ class ModuleShopClientController extends AdminController
*/
public function actionIndex(int $page_number = 1): void
{
if ($this->moduleService->issetModuleShopToken()) {
if ($this->moduleService->isServerAvailable()) {
$request = new Request();
$filters = $request->get();
$per_page = 8;
$modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
$modules = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
$modules = json_decode($modules->getBody()->getContents(), true);
if ($filters) {
$modules_info = [];
foreach ($modules as $module) {
foreach ($filters as $key => $value) {
if ($value === '') continue;
if ($module[$key] !== $value) {
break;
}
$modules_info[] = $module;
}
}
} else {
$modules_info = $modules;
}
$module_count = count($modules_info);
$modules_info = array_slice($modules_info, $per_page * ($page_number - 1), $per_page);

View File

@ -0,0 +1,16 @@
<?php
namespace kernel\modules\module_shop_client\services;
use kernel\helpers\RESTClient;
class ModuleShopClientService
{
public function getModulesInfo(string $url)
{
// $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);
}
}

View File

@ -19,7 +19,8 @@ $table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
'currentPage' => $page_number,
'perPage' => 3,
'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/post"
'baseUrl' => "/admin/post",
'showFiltersRow' => false,
]));
$view->setTitle("Список постов");

View File

@ -117,7 +117,7 @@ class AdminThemeService
$modulesInfo = json_decode($modulesInfo->getBody()->getContents(), true);
$themeInfo = $this->getAdminThemeInfo($slug);
Debug::dd($themeInfo);
// Debug::dd($themeInfo);
foreach ($modulesInfo as $mod) {
if ($mod['slug'] === $themeInfo['slug'] && $mod['version'] === $themeInfo['version']) {
return true;