/** * Clear some or all callbacks from an event. * * @param string name * @param array callback * @return void */ public static function clear($name = NULL, array $callback = NULL) { if (NULL === $name and NULL === $callback) { // Clear all events Event::$_events = array(); return; } if (NULL === $callback) { // Clear named events Event::$_events[$name] = array(); return; } // If the name does not exist or the callback cannot be found, return if (!isset(Event::$_events[$name]) or FALSE === ($key = array_search($callback, Event::$_events[$name], TRUE))) { return; } // Unset the callback unset(Event::$_events[$name][$key]); // Reset the array to preserve ordering Event::$_events[$name] = array_values(Event::$_events[$name]); return; }