is server available
This commit is contained in:
parent
a1bed2d9f2
commit
13978449a2
@ -17,6 +17,8 @@ class ModuleService
|
|||||||
{
|
{
|
||||||
protected array $errors = [];
|
protected array $errors = [];
|
||||||
|
|
||||||
|
protected null|bool $serverAvailable = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $module
|
* @param string $module
|
||||||
* @return false|array|string
|
* @return false|array|string
|
||||||
@ -442,7 +444,7 @@ class ModuleService
|
|||||||
|
|
||||||
public function isLastVersion(string $slug): bool
|
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 = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/gb_slug');
|
||||||
|
|
||||||
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
|
$modules_info = json_decode($modules_info->getBody()->getContents(), true);
|
||||||
@ -452,8 +454,6 @@ class ModuleService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
|
||||||
throw new \Exception("Не удалось получить доступ к магазину модулей");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -482,4 +482,21 @@ class ModuleService
|
|||||||
return $modules_info;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -75,7 +75,7 @@ $table->addAction(function ($row) use ($moduleService){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($moduleService->isActive('module_shop_client')) {
|
if ($moduleService->isActive('module_shop_client') && $moduleService->isServerAvailable()) {
|
||||||
ModuleTabsWidget::create()->run();
|
ModuleTabsWidget::create()->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user