module manager
This commit is contained in:
50
kernel/controllers/ModuleController.php
Normal file
50
kernel/controllers/ModuleController.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\controllers;
|
||||
|
||||
use DirectoryIterator;
|
||||
use kernel\AdminController;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\models\Option;
|
||||
use kernel\modules\user\service\UserService;
|
||||
use kernel\services\ModuleService;
|
||||
|
||||
class ModuleController extends AdminController
|
||||
{
|
||||
protected ModuleService $moduleService;
|
||||
|
||||
protected function init(): void
|
||||
{
|
||||
parent::init();
|
||||
$this->cgView->viewPath = KERNEL_DIR . "/views/module/";
|
||||
|
||||
$this->moduleService = new ModuleService();
|
||||
}
|
||||
|
||||
public function actionIndex(): void
|
||||
{
|
||||
$admin_theme_paths = Option::where("key", "module_paths")->first();
|
||||
$dirs = [];
|
||||
if ($admin_theme_paths){
|
||||
$path = json_decode($admin_theme_paths->value);
|
||||
foreach ($path->paths as $p){
|
||||
$dirs[] = getConst($p);
|
||||
}
|
||||
}
|
||||
|
||||
$modules_info = [];
|
||||
foreach ($dirs as $dir){
|
||||
$i = 1;
|
||||
foreach (new DirectoryIterator($dir) as $fileInfo) {
|
||||
$info = [];
|
||||
if($fileInfo->isDot()) continue;
|
||||
$info['id'] = $i;
|
||||
$modules_info[] = array_merge($info, $this->moduleService->getModuleInfo($fileInfo->getPathname()));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->cgView->render("index.php", ['modules_info' => $modules_info, 'moduleService' => $this->moduleService]);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user