mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
Support event handlers (triggers) that are only called before/after specific action
This commit is contained in:
parent
e0a828079b
commit
48e0f55d6b
1 changed files with 13 additions and 0 deletions
|
|
@ -748,6 +748,16 @@ class ModuleObject extends BaseObject
|
||||||
Context::set('module_info', $this->module_info);
|
Context::set('module_info', $this->module_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Trigger before specific action
|
||||||
|
$triggerAct = sprintf('act:%s.%s', $this->module, $this->act);
|
||||||
|
$triggerOutput = ModuleHandler::triggerCall($triggerAct, 'before', $this);
|
||||||
|
if(!$triggerOutput->toBool())
|
||||||
|
{
|
||||||
|
$this->setError($triggerOutput->getError());
|
||||||
|
$this->setMessage($triggerOutput->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Run
|
// Run
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -759,6 +769,9 @@ class ModuleObject extends BaseObject
|
||||||
$location = $e->getFile() . ':' . $e->getLine();
|
$location = $e->getFile() . ':' . $e->getLine();
|
||||||
$output->add('rx_error_location', $location);
|
$output->add('rx_error_location', $location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Trigger after specific action
|
||||||
|
ModuleHandler::triggerCall($triggerAct, 'after', $output);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue