Support global routes

This commit is contained in:
Kijin Sung 2020-06-18 16:36:27 +09:00
parent 7e47c1cb8a
commit c8a6b8de79
8 changed files with 94 additions and 41 deletions

View file

@ -135,6 +135,7 @@ class module extends ModuleObject
// check route columns in action_forward table
if(!$oDB->isColumnExists('action_forward', 'route_regexp')) return true;
if(!$oDB->isColumnExists('action_forward', 'route_config')) return true;
if(!$oDB->isColumnExists('action_forward', 'global_route')) return true;
}
/**
@ -462,6 +463,10 @@ class module extends ModuleObject
{
$oDB->addColumn('action_forward', 'route_config', 'text');
}
if(!$oDB->isColumnExists('action_forward', 'global_route'))
{
$oDB->addColumn('action_forward', 'global_route', 'char', 1, 'N', true);
}
}
/**

View file

@ -19,14 +19,15 @@ class moduleController extends module
* Action forward finds and forwards if an action is not in the requested module
* This is used when installing a module
*/
function insertActionForward($module, $type, $act, $route_regexp = null, $route_config = null)
function insertActionForward($module, $type, $act, $route_regexp = null, $route_config = null, $global_route = 'N')
{
$args = new stdClass();
$args->module = $module;
$args->type = $type;
$args->act = $act;
$args->route_regexp = $route_regexp;
$args->route_config = $route_config;
$args->route_regexp = serialize($route_regexp);
$args->route_config = serialize($route_config);
$args->global_route = $global_route === 'Y' ? 'Y' : 'N';
$output = executeQuery('module.insertActionForward', $args);
Rhymix\Framework\Cache::delete('action_forward');
@ -1337,6 +1338,7 @@ class moduleController extends module
'type' => $module_action_info->action->{$action_name}->type,
'regexp' => array(),
'config' => $action_info->route,
'global_route' => $action_info->global_route ? 'Y' : 'N',
);
}
}
@ -1368,7 +1370,8 @@ class moduleController extends module
}
}
elseif ($action_forward[$action_name]->route_regexp !== $route_info['regexp'] ||
$action_forward[$action_name]->route_config !== $route_info['config'])
$action_forward[$action_name]->route_config !== $route_info['config'] ||
$action_forward[$action_name]->global_route !== $route_info['global_route'])
{
$output = $this->deleteActionForward($module_name, $route_info['type'], $action_name);
if (!$output->toBool())
@ -1377,7 +1380,7 @@ class moduleController extends module
}
$output = $this->insertActionForward($module_name, $route_info['type'], $action_name,
serialize($route_info['regexp']), serialize($route_info['config']));
$route_info['regexp'], $route_info['config'], $route_info['global_route']);
if (!$output->toBool())
{
return $output;

View file

@ -8,5 +8,6 @@
<column name="type" var="type" notnull="notnull" />
<column name="route_regexp" var="route_regexp" />
<column name="route_config" var="route_config" />
<column name="global_route" var="global_route" default="N" />
</columns>
</query>

View file

@ -4,4 +4,5 @@
<column name="type" type="varchar" size="15" notnull="notnull" />
<column name="route_regexp" type="text" />
<column name="route_config" type="text" />
<column name="global_route" type="char" size="1" notnull="notnull" default="N" />
</table>