module manager
This commit is contained in:
39
kernel/services/ModuleService.php
Normal file
39
kernel/services/ModuleService.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\services;
|
||||
|
||||
use kernel\helpers\Manifest;
|
||||
use kernel\models\Option;
|
||||
|
||||
class ModuleService
|
||||
{
|
||||
|
||||
public function getModuleInfo(string $module): false|array|string
|
||||
{
|
||||
$info = [];
|
||||
$info['path'] = $module;
|
||||
if (file_exists($module . "/manifest.json")){
|
||||
$manifest = file_get_contents($module . "/manifest.json");
|
||||
$manifest = Manifest::getWithVars($manifest);
|
||||
$info = array_merge($info, $manifest);
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
public function isActive(string $slug): bool
|
||||
{
|
||||
$active_modules= Option::where("key", "active_modules")->first();
|
||||
if ($active_modules){
|
||||
$path = json_decode($active_modules->value);
|
||||
foreach ($path->modules as $p){
|
||||
if ($p === $slug){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user