mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
Use associative array to store custom namespaces
This commit is contained in:
parent
911772393a
commit
a7954506f6
5 changed files with 22 additions and 22 deletions
|
|
@ -1463,20 +1463,20 @@ class ModuleController extends Module
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!isset($namespaces[$name]))
|
||||
if (!isset($namespaces['mapping'][$name]))
|
||||
{
|
||||
$namespaces[$name] = 'modules/' . $module_name;
|
||||
$namespaces['mapping'][$name] = 'modules/' . $module_name;
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove namespaces that are no longer defined by this module.
|
||||
foreach ($namespaces as $name => $path)
|
||||
foreach ($namespaces['mapping'] ?? [] as $name => $path)
|
||||
{
|
||||
$attached_module = preg_replace('!^modules/!', '', $path);
|
||||
if ($attached_module === $module_name && !in_array($name, $module_action_info->namespaces ?? []))
|
||||
{
|
||||
unset($namespaces[$name]);
|
||||
unset($namespaces['mapping'][$name]);
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1484,7 +1484,7 @@ class ModuleController extends Module
|
|||
// Generate a regular expression for routing.
|
||||
$regexp = [];
|
||||
unset($namespaces['regexp']);
|
||||
foreach ($namespaces as $name => $path)
|
||||
foreach ($namespaces['mapping'] ?? [] as $name => $path)
|
||||
{
|
||||
$regexp[] = preg_quote(strtr($name, '\\', '/'), '!');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue