X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=app%2FController%2FGithub.php;h=5933fcd2ffc12aee7ccf5ef74a79daaea9e6e3dd;hb=26494fb5cdfb9cf103904d10b6bda564bcf2d0bd;hp=49b14885be7eb986f88e88e73a884ac0a67ee961;hpb=ebc0d017c8a24bd16ca1f4347b39b07ba4349135;p=pharext%2Fpharext.org diff --git a/app/Controller/Github.php b/app/Controller/Github.php index 49b1488..5933fcd 100644 --- a/app/Controller/Github.php +++ b/app/Controller/Github.php @@ -26,11 +26,15 @@ abstract class Github implements Controller * @var \app\Session */ protected $session; - - function __construct(Web $app, API $github) { + + function __construct(Web $app, API $github, Session $session) { $this->app = $app; $this->github = $github; - $this->app->getView()->addData(["location" => "github"]); + $this->session = $session; + $this->app->getView()->addData(compact("session") + [ + "location" => "github", + "title" => "Github" + ]); $this->app->getView()->registerFunction("check", [$this, "checkRepoHook"]); } @@ -45,19 +49,20 @@ abstract class Github implements Controller return false; } - function setSession(Session $session) { - $this->session = $session; - } - + /** + * Check if the pharext webhook is set for the repo and return its id + * @param object $repo + * @return int hook id + */ function checkRepoHook($repo) { if ($repo->hooks) { foreach ($repo->hooks as $hook) { if ($hook->name === "web" && $hook->config->url === $this->github->getConfig()->hook->url) { - return true; + return $hook->id; } } } - return false; + return null; } function createLinkGenerator($links) {