mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 17:44:38 +09:00
Add support for the generic mid/act URL pattern
This commit is contained in:
parent
f02c4aa4c4
commit
b706f2f6ab
1 changed files with 11 additions and 1 deletions
|
|
@ -82,11 +82,14 @@ class Router
|
||||||
$prefix = $matches[1];
|
$prefix = $matches[1];
|
||||||
$internal_url = $matches[2] ?? '';
|
$internal_url = $matches[2] ?? '';
|
||||||
|
|
||||||
// Get the list of routes defined by the module.
|
// Find the module associated with this prefix.
|
||||||
$module_info = \ModuleModel::getModuleInfoByMid($prefix);
|
$module_info = \ModuleModel::getModuleInfoByMid($prefix);
|
||||||
if ($module_info && $module_info->module)
|
if ($module_info && $module_info->module)
|
||||||
{
|
{
|
||||||
|
// Get module actions.
|
||||||
$action_info = \ModuleModel::getModuleActionXml($module_info->module);
|
$action_info = \ModuleModel::getModuleActionXml($module_info->module);
|
||||||
|
|
||||||
|
// Try the list of routes defined by the module.
|
||||||
foreach ($action_info->route->{$method} as $regexp => $action)
|
foreach ($action_info->route->{$method} as $regexp => $action)
|
||||||
{
|
{
|
||||||
if (preg_match($regexp, $internal_url, $matches))
|
if (preg_match($regexp, $internal_url, $matches))
|
||||||
|
|
@ -96,6 +99,13 @@ class Router
|
||||||
return $allargs;
|
return $allargs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try the generic mid/act pattern.
|
||||||
|
if (preg_match('#^[a-zA-Z0-9_]+$#', $internal_url) && isset($action_info->action->{$internal_url}) && !$action_info->action->{$internal_url}->route)
|
||||||
|
{
|
||||||
|
$allargs = array_merge(['mid' => $prefix, 'act' => $internal_url], $args);
|
||||||
|
return $allargs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue