inital commit
[pharext/pharext.org] / app / Controller / Github / Index.php
1 <?php
2
3 namespace app\Controller\Github;
4
5 use app\Controller\Github;
6
7 use http\QueryString;
8
9 class Index extends Github
10 {
11 function __invoke(array $args = null) {
12 if ($this->checkToken()) {
13 try {
14 $this->github->fetchRepos(
15 $this->app->getRequest()->getQuery("page"),
16 [$this, "reposCallback"]
17 )->send();
18 } catch (\app\Github\Exception $exception) {
19 $this->view->addData(compact("exception"));
20 }
21 $this->app->display("github/index");
22 }
23 }
24
25 function reposCallback($repos, $links) {
26 $this->app->getView()->addData(compact("repos"));
27 $this->app->getView()->registerFunction("link", $this->createLinkGenerator($links));
28
29 foreach ($repos as $repo) {
30 $this->github->fetchHooks($repo->full_name, function($hooks) use($repo) {
31 $repo->hooks = $hooks;
32 });
33 }
34 }
35 }