module activate

This commit is contained in:
2024-09-13 13:54:58 +03:00
parent 95e80ab87b
commit fc80a63a6d
6 changed files with 56 additions and 74 deletions

View File

@ -2,6 +2,7 @@
namespace kernel\services;
use kernel\helpers\Debug;
use kernel\helpers\Manifest;
use kernel\models\Option;
@ -23,7 +24,7 @@ class ModuleService
public function isActive(string $slug): bool
{
$active_modules= Option::where("key", "active_modules")->first();
$active_modules = Option::where("key", "active_modules")->first();
if ($active_modules){
$path = json_decode($active_modules->value);
foreach ($path->modules as $p){
@ -36,4 +37,18 @@ class ModuleService
return false;
}
public function setActiveModule(string $module): void
{
$active_modules = Option::where("key", "active_modules")->first();
$path = json_decode($active_modules->value);
if (in_array($module, $path->modules)) {
unset($path->modules[array_search($module, $path->modules)]);
$path->modules = array_values($path->modules);
} else {
$path->modules[] = $module;
}
$active_modules->value = json_encode($path, JSON_UNESCAPED_UNICODE);
$active_modules->save();
}
}