yet another github api refactoring
[pharext/pharext.org] / app / Github / API / Repos / ReleasesCallback.php
diff --git a/app/Github/API/Repos/ReleasesCallback.php b/app/Github/API/Repos/ReleasesCallback.php
new file mode 100644 (file)
index 0000000..aca8575
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+namespace app\Github\API\Repos;
+
+use app\Github\API;
+use app\Github\API\Callback;
+
+class ReleasesCallback extends Callback
+{
+       private $repo;
+       
+       function __construct(API $api, $repo) {
+               parent::__construct($api);
+               $this->repo = $repo;
+       }
+       
+       function __invoke($json, $links = null) {
+               settype($this->repo->tags, "object");
+               foreach ($json as $release) {
+                       $tag = $release->tag_name;
+                       settype($this->repo->tags->$tag, "object");
+                       $this->repo->tags->$tag->release = $release;
+                       $this->api->listReleaseAssets($this->repo->full_name, $release->id, function($assets) use($release) {
+                               $release->assets = $assets;
+                       });
+               }
+       }
+}