flush
[pharext/pharext.org] / app / Controller / Github / Repo.php
index f194d8e726b91ac52294e1651a542b95d0d8ea4e..ac2ce37d5916cebdb2a3fc68e8cb39f4c2fa1202 100644 (file)
@@ -8,15 +8,12 @@ class Repo extends Github
 {
        function __invoke(array $args = null) {
                extract($args);
+               $this->app->getView()->addData(compact("owner", "name"));
                if ($this->checkToken()) {
-                       try {
-                               $this->github->fetchRepo(
-                                       "$owner/$name",
-                                       [$this, "repoCallback"]
-                               )->send();
-                       } catch (\app\Github\Exception $exception) {
-                               $this->app->getView()->addData(compact("exception", "owner", "name"));
-                       }
+                       $this->github->readRepo(
+                               "$owner/$name",
+                               [$this, "repoCallback"]
+                       )->send();
                        
                        if (($modal = $this->app->getRequest()->getQuery("modal"))) {
                                $this->app->getView()->addData(compact("modal") + [
@@ -28,17 +25,18 @@ class Repo extends Github
                }
        }
 
-       function repoCallback($repo, $links) {
+       function repoCallback($repo) {
                $this->app->getView()->addData(compact("repo") + [
                        "title" => "Github: {$repo->name}"
                ]);
                settype($repo->tags, "object");
-               $this->github->fetchHooks($repo->full_name, function($hooks) use($repo) {
+               $this->github->listHooks($repo->full_name, function($hooks) use($repo) {
                        $repo->hooks = $hooks;
+                       $this->app->getView()->addData(["hook" => $this->checkRepoHook($repo)]);
                });
-               $this->github->fetchTags($repo->full_name, 1, $this->createTagsCallback($repo));
-               $this->github->fetchReleases($repo->full_name, 1, $this->createReleasesCallback($repo));
-               $this->github->fetchContents($repo->full_name, null, $this->createContentsCallback($repo));
+               $this->github->listTags($repo->full_name, 1, $this->createTagsCallback($repo));
+               $this->github->listReleases($repo->full_name, 1, $this->createReleasesCallback($repo));
+               $this->github->readContents($repo->full_name, null, $this->createContentsCallback($repo));
        }
 
        function createReleasesCallback($repo) {
@@ -47,6 +45,9 @@ class Repo extends Github
                                $tag = $release->tag_name;
                                settype($repo->tags->$tag, "object");
                                $repo->tags->$tag->release = $release;
+                               $this->github->listReleaseAssets($repo->full_name, $release->id, function($assets) use($release) {
+                                       $release->assets = $assets;
+                               });
                        }
                };
        }