recusive activate dependencies

This commit is contained in:
2025-01-23 16:57:03 +03:00
parent 11c99be0f6
commit b6ba8f8718
5 changed files with 91 additions and 18 deletions

View File

@ -3,6 +3,7 @@
namespace kernel\services;
use DirectoryIterator;
use Josantonius\Session\Facades\Session;
use kernel\Flash;
use kernel\helpers\Debug;
use kernel\helpers\Files;
@ -69,28 +70,29 @@ class ThemeService
$activeTheme = $this->option::where("key", "active_theme")->first();
$themeInfo = $this->getThemeInfo(getConst($theme));
if (isset($themeInfo['dependence'])) {
$dependence_array = explode(',', $themeInfo['dependence']);
foreach ($dependence_array as $depend) {
if (!$this->moduleService->isInstall($depend)) {
if ($this->moduleService->isShopModule($depend)) {
$this->moduleShopService->installModule($depend);
} else {
Flash::setMessage("error", "Модуль не найден в IT Guild Framework Shop.");
return false;
}
} else {
if (!$this->moduleService->isActive($depend)) {
$this->moduleService->setActiveModule($depend);
}
$dependenceArray = RESTClient::request($_ENV['MODULE_SHOP_URL'] . '/api/module_shop/get_all_dependencies/' . $themeInfo['slug']);
$dependenceArray = json_decode($dependenceArray->getBody()->getContents(), true);
foreach ($dependenceArray as $depend) {
if (!$this->moduleService->isInstall($depend)) {
if (!$this->moduleShopService->existsInModuleShop($depend)) {
Flash::setMessage('error', "Модуль $depend не найден в IT Guild Framework Shop.");
return false;
}
}
}
if (!$this->moduleService->recursiveActivateDependencies($dependenceArray)){
return false;
}
$activeTheme->value = getConst($theme);
$activeTheme->save();
return true;
}
public function getActiveThemeInfo(): false|array|string