X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fevent.php;h=4ccee17e666bc770d45b7ebac03f3b77dc918a2d;hb=7a6827258032f9d082f093c741125262ddeb81da;hp=10ef5ec0a9a1b74c4ca361bba0a07011c4e04ba7;hpb=e40d503dfb1b929c7e91422e7ee103a2cf37288d;p=quix0rs-gnu-social.git diff --git a/lib/event.php b/lib/event.php index 10ef5ec0a9..4ccee17e66 100644 --- a/lib/event.php +++ b/lib/event.php @@ -98,7 +98,7 @@ class Event { * on results of handlers. */ - public static function handle($name, $args) { + public static function handle($name, $args=array()) { $result = null; if (array_key_exists($name, Event::$_handlers)) { foreach (Event::$_handlers[$name] as $handler) { @@ -110,4 +110,32 @@ class Event { } return ($result !== false); } + + /** + * Check to see if an event handler exists + * + * Look to see if there's any handler for a given event, or narrow + * by providing the name of a specific plugin class. + * + * @param string $name Name of the event to look for + * @param string $plugin Optional name of the plugin class to look for + * + * @return boolean flag saying whether such a handler exists + * + */ + + public static function hasHandler($name, $plugin=null) { + if (array_key_exists($name, Event::$_handlers)) { + if (isset($plugin)) { + foreach (Event::$_handlers[$name] as $handler) { + if (get_class($handler[0]) == $plugin) { + return true; + } + } + } else { + return true; + } + } + return false; + } }