49b14885be7eb986f88e88e73a884ac0a67ee961
3 namespace app\Controller
;
13 abstract class Github
implements Controller
21 * @var \app\Github\API
30 function __construct(Web
$app, API
$github) {
32 $this->github
= $github;
33 $this->app
->getView()->addData(["location" => "github"]);
34 $this->app
->getView()->registerFunction("check", [$this, "checkRepoHook"]);
37 protected function checkToken() {
38 if ($this->github
->hasToken()) {
41 $this->app
->redirect($this->app
->getBaseUrl()->mod([
42 "path" => "github/signin",
43 "query" => new QueryString(["returnto" => $this->session
->current
])
48 function setSession(Session
$session) {
49 $this->session
= $session;
52 function checkRepoHook($repo) {
54 foreach ($repo->hooks
as $hook) {
55 if ($hook->name
=== "web" && $hook->config
->url
=== $this->github
->getConfig()->hook
->url
) {
63 function createLinkGenerator($links) {
64 return function($which) use($links) {
65 if (!isset($links[$which])) {
66 if ($which !== "next" ||
!isset($links["last"])) {
72 $url = new Url($links[$which], null, 0);
73 $qry = new QueryString($url->query
);
74 return $qry->getInt("page", 1);