use starge driver prefix option
[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 $logger = new Github\Logger($config);
20
21 // FIXME: configure through app.ini
22 try {
23 $cache = new Github\Storage\Redis("gh-cache");
24 } catch (\Exception $ex) {
25 /* Memcached won't throw an exception */
26 $cache = new Github\Storage\Memcache("gh-cache");
27 }
28 return new Github\API(
29 $config->github
30 ,$logger
31 ,new Github\Storage\Session("gh-tokens")
32 ,$cache
33 );
34 });
35