github: fix notices
[pharext/pharext.org] / app / Controller / Github / Release.php
1 <?php
2
3 namespace app\Controller\Github;
4
5 use app\Controller\Github;
6 use app\Github\API\Repos\RepoCallback;
7
8 class Release extends Github
9 {
10 function __invoke(array $args = null) {
11 if (!$this->checkToken()) {
12 return;
13 }
14
15 extract($args);
16 $this->github->readRepo("$owner/$name")->then(
17 new RepoCallback($this->github)
18 )->then(function($result) use(&$repo) {
19 list($repo,,,$releases) = $result;
20 $config = $this->app->getRequest()->getForm();
21
22 foreach ($releases as $release) {
23 if ($release->tag_name === $config["tag"]) {
24 return $this->github->uploadAssetForRelease($repo, $release, $config);
25 }
26 }
27
28 return $this->github->createReleaseFromTag($repo, $config["tag"], $config);
29 })->done(function() use(&$repo) {
30 $this->app->redirect($this->app->getBaseUrl()->mod(":./github/repo/" . $repo->full_name));
31 });
32
33 $this->github->drain();
34
35 $hook = $this->github->checkRepoHook($repo);
36 $this->app->getView()->addData(compact("owner", "name", "repo", "hook"));
37
38 if (($modal = $this->app->getRequest()->getQuery("modal"))) {
39 $action = $this->app->getRequest()->getQuery($modal);
40 $this->app->getView()->addData(compact("modal", "action"));
41 }
42
43 $this->app->display("github/repo");
44 }
45 }