X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=inline;f=app%2FController%2FGithub%2FIndex.php;h=343c16f7e922b15be2942e3838ade6a726b29ec8;hb=HEAD;hp=c0838b7912af788da3fe83c9a276804b617d0818;hpb=eb76e9bb9a39fe2725301f6cf6fc3cf29bbc4e00;p=pharext%2Fpharext.org diff --git a/app/Controller/Github/Index.php b/app/Controller/Github/Index.php index c0838b7..343c16f 100644 --- a/app/Controller/Github/Index.php +++ b/app/Controller/Github/Index.php @@ -3,26 +3,23 @@ namespace app\Controller\Github; use app\Controller\Github; +use app\Github\API\Repos\ReposCallback; class Index extends Github { function __invoke(array $args = null) { - if ($this->checkToken()) { - $this->github->listRepos( - $this->app->getRequest()->getQuery("page"), - [$this, "reposCallback"] - )->send(); - $this->app->display("github/index"); + if (!$this->checkToken()) { + return; } - } - - function reposCallback($repos, $links) { - $this->app->getView()->addData(compact("repos", "links")); + $this->github->listRepos( + $this->app->getRequest()->getQuery("page") + )->then( + new ReposCallback($this->github) + )->done(function($results) { + list(list($repos, $links)) = $results; + $this->app->display("github/index", compact("repos", "links")); + }); - foreach ($repos as $repo) { - $this->github->listHooks($repo->full_name, function($hooks) use($repo) { - $repo->hooks = $hooks; - }); - } + $this->github->drain(); } }