refactor guthub api
[pharext/pharext.org] / app / Controller / Github / Index.php
1 <?php
2
3 namespace app\Controller\Github;
4
5 use app\Controller\Github;
6
7 class Index extends Github
8 {
9 function __invoke(array $args = null) {
10 if ($this->checkToken()) {
11 $this->github->fetchRepos(
12 $this->app->getRequest()->getQuery("page"),
13 [$this, "reposCallback"]
14 )->send();
15 $this->app->display("github/index");
16 }
17 }
18
19 function reposCallback($repos, $links) {
20 $this->app->getView()->addData(compact("repos", "links"));
21
22 foreach ($repos as $repo) {
23 $this->github->fetchHooks($repo->full_name, function($hooks) use($repo) {
24 $repo->hooks = $hooks;
25 });
26 }
27 }
28 }