Support event handlers (triggers) that are only called before/after specific action

This commit is contained in:
Kijin Sung 2023-08-12 01:14:36 +09:00
parent e0a828079b
commit 48e0f55d6b

View file

@ -748,6 +748,16 @@ class ModuleObject extends BaseObject
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
try
{
@ -759,6 +769,9 @@ class ModuleObject extends BaseObject
$location = $e->getFile() . ':' . $e->getLine();
$output->add('rx_error_location', $location);
}
// Trigger after specific action
ModuleHandler::triggerCall($triggerAct, 'after', $output);
}
else
{