fix: add support of module name aliases in the router

This commit is contained in:
Matthieu Bessat 2021-08-08 20:29:34 +02:00
parent 7a34d841cc
commit abd4773e16

View file

@ -29,12 +29,14 @@ function generateHelp($selectedModule) {
$modules = $config['modules']; $modules = $config['modules'];
$selectedModule = null; $selectedModule = null;
foreach ($modules as $key => $module) { foreach ($modules as $moduleName => $module) {
if (strpos($_SERVER['HTTP_HOST'], $key . '.') === 0) { foreach (array_merge([$moduleName], $module['alias'] ?? []) as $alias) {
if (strpos($_SERVER['HTTP_HOST'], $alias . '.') === 0) {
$selectedModule = $module; $selectedModule = $module;
$selectedModule['key'] = $key; $selectedModule['key'] = $moduleName;
break; break;
} }
}
} }
if ($selectedModule === null) { if ($selectedModule === null) {