mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
Register event handlers and custom namespaces defined in module.xml
This commit is contained in:
parent
d0306df095
commit
acc1117d26
4 changed files with 119 additions and 0 deletions
|
|
@ -135,6 +135,7 @@ return array(
|
||||||
'tablets' => false,
|
'tablets' => false,
|
||||||
'viewport' => 'width=device-width, initial-scale=1.0, user-scalable=yes',
|
'viewport' => 'width=device-width, initial-scale=1.0, user-scalable=yes',
|
||||||
),
|
),
|
||||||
|
'namespaces' => [],
|
||||||
'use_rewrite' => true,
|
'use_rewrite' => true,
|
||||||
'use_sso' => false,
|
'use_sso' => false,
|
||||||
'other' => array(),
|
'other' => array(),
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,27 @@ class installAdminController extends install
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$output = $oModuleController->registerEventHandlers($module_name);
|
||||||
|
if($output instanceof BaseObject && !$output->toBool())
|
||||||
|
{
|
||||||
|
Rhymix\Framework\Session::start();
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = $oModuleController->registerNamespaces($module_name);
|
||||||
|
if($output instanceof BaseObject && !$output->toBool())
|
||||||
|
{
|
||||||
|
Rhymix\Framework\Session::start();
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = $oModuleController->registerPrefixes($module_name);
|
||||||
|
if($output instanceof BaseObject && !$output->toBool())
|
||||||
|
{
|
||||||
|
Rhymix\Framework\Session::start();
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
Rhymix\Framework\Session::start();
|
Rhymix\Framework\Session::start();
|
||||||
$this->setMessage('success_updated');
|
$this->setMessage('success_updated');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1388,6 +1388,73 @@ class ModuleController extends Module
|
||||||
|
|
||||||
return new BaseObject();
|
return new BaseObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if all event handlers are registered. If not, register them.
|
||||||
|
*
|
||||||
|
* @param string $module_name
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function registerEventHandlers(string $module_name)
|
||||||
|
{
|
||||||
|
$module_action_info = ModuleModel::getModuleActionXml($module_name);
|
||||||
|
|
||||||
|
foreach ($module_action_info->event_handlers ?? [] as $ev)
|
||||||
|
{
|
||||||
|
if(!ModuleModel::getTrigger($ev->event_name, $module_name, $ev->class_name, $ev->method, $ev->position))
|
||||||
|
{
|
||||||
|
$output = $this->insertTrigger($ev->event_name, $module_name, $ev->class_name, $ev->method, $ev->position);
|
||||||
|
if (!$output->toBool())
|
||||||
|
{
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BaseObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if all custom namespaces are registered. If not, register them.
|
||||||
|
*
|
||||||
|
* @param string $module_name
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function registerNamespaces(string $module_name)
|
||||||
|
{
|
||||||
|
$module_action_info = ModuleModel::getModuleActionXml($module_name);
|
||||||
|
$namespaces = config('namespaces') ?? [];
|
||||||
|
$changed = false;
|
||||||
|
|
||||||
|
foreach ($module_action_info->namespaces ?? [] as $name)
|
||||||
|
{
|
||||||
|
if(!isset($namespaces[$name]))
|
||||||
|
{
|
||||||
|
$namespaces[$name] = $module_name;
|
||||||
|
$changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($changed)
|
||||||
|
{
|
||||||
|
Rhymix\Framework\Config::set('namespaces', $namespaces);
|
||||||
|
Rhymix\Framework\Config::save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BaseObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if all prefixes for a module are registered. If not, register them.
|
||||||
|
*
|
||||||
|
* @param string $module_name
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function registerPrefixes(string $module_name)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
return new BaseObject();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* End of file module.controller.php */
|
/* End of file module.controller.php */
|
||||||
/* Location: ./modules/module/module.controller.php */
|
/* Location: ./modules/module/module.controller.php */
|
||||||
|
|
|
||||||
|
|
@ -1631,9 +1631,39 @@ class ModuleModel extends Module
|
||||||
$info->need_update = true;
|
$info->need_update = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if all event handlers are registered.
|
||||||
|
foreach ($module_action_info->event_handlers ?? [] as $ev)
|
||||||
|
{
|
||||||
|
if(!ModuleModel::getTrigger($ev->event_name, $module_name, $ev->class_name, $ev->method, $ev->position))
|
||||||
|
{
|
||||||
|
$info->need_update = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if all namespaces are registered.
|
||||||
|
$namespaces = config('namespaces') ?? [];
|
||||||
|
foreach ($module_action_info->namespaces ?? [] as $name)
|
||||||
|
{
|
||||||
|
if(!isset($namespaces[$name]))
|
||||||
|
{
|
||||||
|
$info->need_update = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if all prefixes are registered.
|
||||||
|
foreach ($module_action_info->prefixes ?? [] as $name)
|
||||||
|
{
|
||||||
|
if(!ModuleModel::getModuleSrlByMid($name))
|
||||||
|
{
|
||||||
|
$info->need_update = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$list[] = $info;
|
$list[] = $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue