From: Zach Copley Date: Fri, 12 Jun 2009 23:56:43 +0000 (-0700) Subject: Add a method to check for registered event handlers X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fc6154fe4dc093780d610f97c0d9213bb26060fe;p=quix0rs-gnu-social.git Add a method to check for registered event handlers --- diff --git a/lib/event.php b/lib/event.php index d815ae54ba..4ccee17e66 100644 --- a/lib/event.php +++ b/lib/event.php @@ -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; + } }