3 namespace app\Controller\Github
;
5 use app\Controller\Github
;
7 class Repo
extends Github
9 function __invoke(array $args = null) {
11 $this->app
->getView()->addData(compact("owner", "name"));
12 if ($this->checkToken()) {
13 $this->github
->fetchRepo(
15 [$this, "repoCallback"]
18 if (($modal = $this->app
->getRequest()->getQuery("modal"))) {
19 $this->app
->getView()->addData(compact("modal") +
[
20 "action" => $this->app
->getRequest()->getQuery($modal)
24 $this->app
->display("github/repo");
28 function repoCallback($repo) {
29 $this->app
->getView()->addData(compact("repo") +
[
30 "title" => "Github: {$repo->name}"
32 settype($repo->tags
, "object");
33 $this->github
->fetchHooks($repo->full_name
, function($hooks) use($repo) {
34 $repo->hooks
= $hooks;
36 $this->github
->fetchTags($repo->full_name
, 1, $this->createTagsCallback($repo));
37 $this->github
->fetchReleases($repo->full_name
, 1, $this->createReleasesCallback($repo));
38 $this->github
->fetchContents($repo->full_name
, null, $this->createContentsCallback($repo));
41 function createReleasesCallback($repo) {
42 return function($releases, $links) use($repo) {
43 foreach ($releases as $release) {
44 $tag = $release->tag_name
;
45 settype($repo->tags
->$tag, "object");
46 $repo->tags
->$tag->release
= $release;
51 function createTagsCallback($repo) {
52 return function($tags, $links) use ($repo) {
53 foreach ($tags as $tag) {
55 settype($repo->tags
->$name, "object");
56 $repo->tags
->$name->tag
= $tag;
61 function createContentsCallback($repo) {
62 return function($tree) use($repo) {
63 foreach ($tree as $entry) {
64 if ($entry->type
!== "file" ||
$entry->size
<= 0) {
67 if ($entry->name
=== "config.m4" ||
fnmatch("config?.m4", $entry->name
)) {
68 $repo->config_m4
= $entry->name
;
69 } elseif ($entry->name
=== "package.xml" ||
$entry->name
=== "package2.xml") {
70 $repo->package_xml
= $entry->name
;
71 } elseif ($entry->name
=== "pharext_package.php") {
72 $repo->pharext_package_php
= $entry->name
;