summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Tuke <samtuke@owncloud.com>2013-02-06 17:43:03 +0000
committerSam Tuke <samtuke@owncloud.com>2013-02-06 17:43:03 +0000
commitae8cfe6569f3c23f162b2d36dfad3aeb3cf5b522 (patch)
tree0616ce784d2f728e065515915fc47002446c8eff
parent81de09711b27bbe5ba421448671bfdf7cf48be22 (diff)
downloadnextcloud-server-ae8cfe6569f3c23f162b2d36dfad3aeb3cf5b522.tar.gz
nextcloud-server-ae8cfe6569f3c23f162b2d36dfad3aeb3cf5b522.zip
Added comments
-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 {