diff --git a/src/App/App.php b/src/App/App.php index d7660b6..f015f40 100755 --- a/src/App/App.php +++ b/src/App/App.php @@ -25,7 +25,21 @@ final class App $this->flash = new Flash($this->session); $this->pdo = Database::createPdo($config); $this->basePdo = Database::createBasePdo($config); - $this->modules = new ModuleManager($this->basePdo, __DIR__ . '/../../modules'); + $modulesPath = $this->config->modulesPath; + if ($modulesPath === '' || !is_dir($modulesPath)) { + $candidates = [ + __DIR__ . '/../../modules', + __DIR__ . '/../modules', + dirname(__DIR__, 3) . '/modules', + ]; + foreach ($candidates as $candidate) { + if (is_dir($candidate)) { + $modulesPath = $candidate; + break; + } + } + } + $this->modules = new ModuleManager($this->basePdo, $modulesPath); $this->modules->bootEnabled(); } diff --git a/src/App/Config.php b/src/App/Config.php index 5e14784..c5fcba0 100755 --- a/src/App/Config.php +++ b/src/App/Config.php @@ -25,6 +25,7 @@ class Config public string $oidcGroupClaim; public string $oidcAdminGroup; public string $oidcUserGroup; + public string $modulesPath; public function __construct( public array $db, @@ -52,6 +53,7 @@ class Config $this->oidcGroupClaim = defined('APP_OIDC_GROUP_CLAIM') ? (string)APP_OIDC_GROUP_CLAIM : 'groups'; $this->oidcAdminGroup = defined('APP_OIDC_ADMIN_GROUP') ? (string)APP_OIDC_ADMIN_GROUP : 'admin'; $this->oidcUserGroup = defined('APP_OIDC_USER_GROUP') ? (string)APP_OIDC_USER_GROUP : 'user'; + $this->modulesPath = defined('APP_MODULES_PATH') ? (string)APP_MODULES_PATH : ''; } public function primaryUrl(): string diff --git a/src/App/ModuleManager.php b/src/App/ModuleManager.php index 2ccde56..a3152d5 100644 --- a/src/App/ModuleManager.php +++ b/src/App/ModuleManager.php @@ -186,6 +186,9 @@ final class ModuleManager { $this->modules = []; if (!is_dir($this->modulesPath)) { + if (defined('APP_DEBUG_TOOL') && APP_DEBUG_TOOL) { + @file_put_contents(__DIR__ . '/../../debug/module_scan.log', 'Modules path not found: ' . $this->modulesPath . PHP_EOL, FILE_APPEND); + } return; } @@ -218,6 +221,10 @@ final class ModuleManager $module['enabled'] = $this->loadEnabledState($name, $module); $this->modules[$name] = $module; } + + if (defined('APP_DEBUG_TOOL') && APP_DEBUG_TOOL) { + @file_put_contents(__DIR__ . '/../../debug/module_scan.log', 'Modules loaded: ' . implode(', ', array_keys($this->modules)) . PHP_EOL, FILE_APPEND); + } } private function loadEnabledState(string $name, array $module): bool