activane module fix

This commit is contained in:
Билай Станислав 2024-09-13 15:45:02 +03:00
parent fc80a63a6d
commit 456d5afec3
2 changed files with 22 additions and 1 deletions

View File

@ -53,7 +53,7 @@ class ModuleController extends AdminController
$request = new Request(); $request = new Request();
$this->moduleService->setActiveModule($request->get("slug")); $this->moduleService->setActiveModule($request->get("slug"));
$this->cgView->render("view.php", ['data' => $this->moduleService->getModuleInfo(KERNEL_MODULES_DIR . '/' . $request->get("slug"))]); $this->cgView->render("view.php", ['data' => $this->moduleService->getModuleInfo($this->moduleService->getModuleDir($request->get("slug")))]);
} }
} }

View File

@ -2,6 +2,7 @@
namespace kernel\services; namespace kernel\services;
use DirectoryIterator;
use kernel\helpers\Debug; use kernel\helpers\Debug;
use kernel\helpers\Manifest; use kernel\helpers\Manifest;
use kernel\models\Option; use kernel\models\Option;
@ -51,4 +52,24 @@ class ModuleService
$active_modules->save(); $active_modules->save();
} }
public function getModuleDir(string $slug)
{
$module_paths = Option::where("key", "module_paths")->first();
$dirs = [];
if ($module_paths){
$path = json_decode($module_paths->value);
foreach ($path->paths as $p){
$dirs[] = getConst($p);
}
}
foreach ($dirs as $dir){
foreach (new DirectoryIterator($dir) as $fileInfo) {
if(basename($fileInfo->getPathname()) !== $slug) continue;
return $fileInfo->getPathname();
}
}
return false;
}
} }