/** * Executes the event calling all callbacks with the given data. * * @return void */ public function execute() { $previousevent = self::$activeevent; self::$activeevent =& $this; $this->_active = TRUE; foreach ($this->_callbacks as $callback) { if ($this->_active === FALSE) { return; } // If the callback has its own data, simply run that data // otherwise, use the Event data and add that if (!empty($callback["data"])) { if (!is_array($callback["data"])) { $callback["data"] = array($callback["data"]); } call_user_func_array($callback["callback"], $callback["data"]); } else { call_user_func_array($callback["callback"], $this->_data); } } self::$activeevent = $previousevent; }