public static function fire($event, &$arg = null) { if (self::is_initializing()) { // PC::EventManager("Queuing event $event"); $queued_event['event'] = $event; $queued_event['arg'] =& $arg; array_push(self::$queue, $queued_event); return false; } if (!array_key_exists($event, self::$events)) { //PC::EventManager("Event $event not found"); return; } //PC::EventManager("Yey firing"); foreach (self::$events[$event] as $callback) { PC::EventManager("Firing event {$event} -> {$callback}"); if (function_exists($callback)) { if ($arg != null) { call_user_func($callback, $arg); } else { call_user_func($callback); } } else { if ($arg != null) { $output = Modules::run($callback, $arg); } else { $output = Modules::run($callback); } } if (isset($output) && $output != "__NO_MODULE__" && $output != "__404__") { echo $output; } } return self::$events[$event] > 0; }