summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZach Copley <zach@controlyourself.ca>2009-06-12 16:56:43 -0700
committerZach Copley <zach@controlyourself.ca>2009-06-12 16:56:43 -0700
commitfc6154fe4dc093780d610f97c0d9213bb26060fe (patch)
tree766398bef66f4cfc5656b0f545c4afb21a772e8c /lib
parent4c61f98cd027df2ed45ed250840405bebc232e1a (diff)
Add a method to check for registered event handlers
Diffstat (limited to 'lib')
-rw-r--r--lib/event.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/event.php b/lib/event.php
index d815ae54b..4ccee17e6 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;
+ }
}