3 namespace app\Controller\Github
;
5 use app\Controller\Github
;
7 class Repo
extends Github
9 function __invoke(array $args = null) {
11 if ($this->checkToken()) {
13 $this->github
->fetchRepo(
15 [$this, "repoCallback"]
17 } catch (\app\Github\Exception
$exception) {
18 $this->app
->getView()->addData(compact("exception", "owner", "name"));
20 $this->app
->display("github/repo");
24 function repoCallback($repo, $links) {
25 $this->app
->getView()->addData(compact("repo"));
26 settype($repo->tags
, "object");
27 $this->github
->fetchHooks($repo->full_name
, function($hooks) use($repo) {
28 $repo->hooks
= $hooks;
30 $this->github
->fetchTags($repo->full_name
, 1, $this->createTagsCallback($repo));
31 $this->github
->fetchReleases($repo->full_name
, 1, $this->createReleasesCallback($repo));
32 $this->github
->fetchContents($repo->full_name
, null, $this->createContentsCallback($repo));
35 function createReleasesCallback($repo) {
36 return function($releases, $links) use($repo) {
37 foreach ($releases as $release) {
38 $tag = $release->tag_name
;
39 settype($repo->tags
->$tag, "object");
40 $repo->tags
->$tag->release
= $release;
45 function createTagsCallback($repo) {
46 return function($tags, $links) use ($repo) {
47 foreach ($tags as $tag) {
49 settype($repo->tags
->$name, "object");
50 $repo->tags
->$name->tag
= $tag;
55 function createContentsCallback($repo) {
56 return function($tree) use($repo) {
57 foreach ($tree as $entry) {
58 if ($entry->type
!== "file" ||
$entry->size
<= 0) {
61 if ($entry->name
=== "config.m4" ||
fnmatch("config?.m4", $entry->name
)) {
62 $repo->config_m4
= $entry->name
;
63 } elseif ($entry->name
=== "package.xml" ||
$entry->name
=== "package2.xml") {
64 $repo->package_xml
= $entry->name
;
65 } elseif ($entry->name
=== "pharext_package.php") {
66 $repo->pharext_package_php
= $entry->name
;