Commit 47661991 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Make handle_event actually work, it seems to be a hangover from the days

when the DB format was different
parent b7018c62
...@@ -645,17 +645,20 @@ function generate_artefact_class_name($type) { ...@@ -645,17 +645,20 @@ function generate_artefact_class_name($type) {
return 'ArtefactType' . ucfirst($type); return 'ArtefactType' . ucfirst($type);
} }
function handle_event($event) { /**
if (!$e = get_record('event_type','name',$event)) { * Fires an event which can be handled by different parts of the system
*/
function handle_event($event, $data) {
if (!$e = get_record('event_type', 'name', $event)) {
throw new Exception("Invalid event"); throw new Exception("Invalid event");
} }
$plugintypes = plugin_types(); $plugintypes = plugin_types();
foreach ($plugintypes as $name) { foreach ($plugintypes as $name) {
if ($subs = get_records_array('event_subscription_' . $name, 'event', $event)) { if ($subs = get_records_array($name . '_event_subscription', 'event', $event)) {
foreach ($subs as $sub) { foreach ($subs as $sub) {
$classname = 'Plugin' . ucfirst($name) . ucfirst($sub->plugin); $classname = 'Plugin' . ucfirst($name) . ucfirst($sub->plugin);
try { try {
call_static_method($classname, $sub->callfunction); call_static_method($classname, $sub->callfunction, $event, $data);
} }
catch (Exception $e) { catch (Exception $e) {
log_warn("Event $event caused an exception from plugin $classname " log_warn("Event $event caused an exception from plugin $classname "
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment