summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/hook.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/hook.php b/lib/hook.php
index 4da331bb5d8..e30aefb5e18 100644
--- a/lib/hook.php
+++ b/lib/hook.php
@@ -20,19 +20,22 @@ class OC_Hook{
* TODO: write example
*/
static public function connect( $signalclass, $signalname, $slotclass, $slotname ) {
- // Create the data structure
+ // If we're trying to connect to an emitting class that isn't
+ // yet registered, register it
if( !array_key_exists( $signalclass, self::$registered )) {
self::$registered[$signalclass] = array();
}
- if( !array_key_exists( $signalname, self::$registered[$signalclass] )) {
+ // If we're trying to connect to an emitting method that isn't
+ // yet registered, register it with the emitting class
+ if( !array_key_exists( $signalname, self::$registered[$signalclass] )) {
self::$registered[$signalclass][$signalname] = array();
}
-
- // register hook
+
+ // Connect the hook handler to the requested emitter
self::$registered[$signalclass][$signalname][] = array(
"class" => $slotclass,
"name" => $slotname );
-
+
// No chance for failure ;-)
return true;
}
@@ -49,14 +52,19 @@ class OC_Hook{
* TODO: write example
*/
static public function emit( $signalclass, $signalname, $params = array()) {
- // Return false if there are no slots
+
+ // Return false if no hook handlers are listening to this
+ // emitting class
if( !array_key_exists( $signalclass, self::$registered )) {
return false;
}
+
+ // Return false if no hook handlers are listening to this
+ // emitting method
if( !array_key_exists( $signalname, self::$registered[$signalclass] )) {
return false;
}
-
+
// Call all slots
foreach( self::$registered[$signalclass][$signalname] as $i ) {
try {