refactored 80%
[pharext/pharext.org] / app / Github / API / Repos / RepoCallback.php
index a3621a5f28d82b9a3abb1bf7289b54aa5f28ab1c..362d8921611f995bf5d4d6b7225e3fa3195a43fb 100644 (file)
@@ -6,12 +6,17 @@ use app\Github\API\Callback;
 use app\Github\API\Hooks\HooksCallback;
 use app\Github\API\Tags\TagsCallback;
 
+use React\Promise;
+
 class RepoCallback extends Callback
 {
-       function __invoke($repo, $links = null) {
-               $this->api->listHooks($repo->full_name, new HooksCallback($this->api, $repo));
-               $this->api->listTags($repo->full_name, 1, new TagsCallback($this->api, $repo));
-               $this->api->listReleases($repo->full_name, 1, new ReleasesCallback($this->api, $repo));
-               $this->api->readContents($repo->full_name, null, new ContentsCallback($this->api, $repo));;
+       protected function exec($repo, $links = null) {
+               return Promise\all([
+                       $repo,
+                       $this->api->listHooks($repo->full_name)->then(new HooksCallback($this->api, $repo)),
+                       $this->api->listTags($repo->full_name, 1)->then(new TagsCallback($this->api, $repo)),
+                       $this->api->listReleases($repo->full_name, 1)->then(new ReleasesCallback($this->api, $repo)),
+                       $this->api->readContents($repo->full_name)->then(new ContentsCallback($this->api, $repo)),
+               ]);
        }
 }