e0defa7bc5482da1f53c647431470e25e1e43eca
[pharext/pharext.org] / app / bootstrap / github.php
1 <?php
2
3 namespace app;
4
5 require_once __DIR__."/config.php";
6
7 use http\Url;
8
9 $injector->share(Github\API::class)
10 ->delegate(Github\API::class, function() use($injector) {
11 $config = $injector->make(Config::class);
12 if (isset($config->github->hook->use_basic_auth)) {
13 $basic = $config->github->hook->use_basic_auth;
14 $config->github->hook->url = (string) new Url(
15 $config->github->hook->url,
16 $config->$basic->auth->toArray(),
17 0);
18 }
19 // FIXME: configure through app.ini
20 try {
21 $cache = new Github\Storage\Redis("gh-cache");
22 } catch (\Exception $ex) {
23 try {
24 $cache = new Github\Storage\Memcache("gh-cache");
25 } catch (\Exception $ex) {
26 $cache = null;
27 }
28 }
29 return new Github\API(
30 $config->github
31 ,new Github\Logger($config)
32 ,new Github\Storage\Session("gh-tokens")
33 ,$cache
34 );
35 });
36