From 8b6ed6c477771e42d43ea0684e5139cf361b6cee Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 28 Nov 2008 19:37:01 +0000 Subject: Create module::event() which runs Gallery events. It works by convention. To respond to the "photo_created" event in the gmaps module, you create modules/gmaps/helpers/gmaps_event.php containing class gmaps_event which has function photo_created. Renamed all events from gallery.foo.bar to foo_bar Updated tag module to use new convention. --- core/helpers/module.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'core/helpers/module.php') diff --git a/core/helpers/module.php b/core/helpers/module.php index fc76c033..afba658a 100644 --- a/core/helpers/module.php +++ b/core/helpers/module.php @@ -54,4 +54,14 @@ class module_Core { public static function installed() { return ORM::factory("module")->find_all(); } + + public static function event($name, &$data=null) { + foreach (self::installed() as $module) { + $class = "{$module->name}_event"; + $function = str_replace(".", "_", $name); + if (method_exists($class, $function)) { + call_user_func_array(array($class, $function), array($data)); + } + } + } } -- cgit v1.2.3