fix hooks
[pharext/pharext.org] / app / Github / API / Call.php
index 3615851693f1870d2094ea70d8a3a018298326f6..ea9b59a70c461e7d0837e6e650c0eaf8c408e573 100644 (file)
@@ -67,7 +67,7 @@ abstract class Call
                }
                
                $this->enqueue($callback);
-               return $this->api->getClient();
+               return $this;
        }
        
        /**
@@ -79,6 +79,13 @@ abstract class Call
                return strtolower(end($parts));
        }
        
+       /**
+        * Call Client::send()
+        */
+       function send() {
+               return $this->api->getClient()->send();
+       }
+       
        /**
         * Get associated cache storage
         * @param int $ttl out param of configure ttl
@@ -92,8 +99,11 @@ abstract class Call
        }
        
        function getCacheKey() {
+               $args = $this->args;
+               unset($args["fresh"]);
+               ksort($args);
                return sprintf("github:%s:%s:%s", $this->api->getToken(), $this, 
-                       new QueryString($this->args));
+                       new QueryString($args));
        }
 
        function readFromCache(array &$cached = null, &$ttl = null) {
@@ -116,4 +126,11 @@ abstract class Call
                        $cache->set($key, $fresh, $ttl);
                }
        }
+       
+       function dropFromCache() {
+               if (($cache = $this->api->getCacheStorage())) {
+                       $key = $this->getCacheKey();
+                       $cache->del($key);
+               }
+       }
 }