diff --git a/kernel/services/ModuleService.php b/kernel/services/ModuleService.php index ac11546..dd2c7d4 100644 --- a/kernel/services/ModuleService.php +++ b/kernel/services/ModuleService.php @@ -17,6 +17,8 @@ class ModuleService { protected array $errors = []; + protected null|bool $serverAvailable = null; + /** * @param string $module * @return false|array|string @@ -442,7 +444,7 @@ class ModuleService public function isLastVersion(string $slug): bool { - try { + if ($this->isServerAvailable()){ $modules_info = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug'); $modules_info = json_decode($modules_info->getBody()->getContents(), true); @@ -452,8 +454,6 @@ class ModuleService return true; } } - } catch (\Exception $e) { - throw new \Exception("Не удалось получить доступ к магазину модулей"); } return false; @@ -482,4 +482,21 @@ class ModuleService return $modules_info; } + public function isServerAvailable(): bool + { + if (null !== $this->serverAvailable){ + return $this->serverAvailable; + } + + try { + RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug'); + $this->serverAvailable = true; + + return true; + } catch (\Exception $e) { + $this->serverAvailable = false; + return false; + } + } + } \ No newline at end of file diff --git a/kernel/views/module/index.php b/kernel/views/module/index.php index 6287a2f..6114995 100644 --- a/kernel/views/module/index.php +++ b/kernel/views/module/index.php @@ -75,7 +75,7 @@ $table->addAction(function ($row) use ($moduleService){ return false; }); -if ($moduleService->isActive('module_shop_client')) { +if ($moduleService->isActive('module_shop_client') && $moduleService->isServerAvailable()) { ModuleTabsWidget::create()->run(); }