* @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"]);
}
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;
}
}
}
- return false;
+ return null;
}
function createLinkGenerator($links) {