-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.php
44 lines (32 loc) · 1.21 KB
/
common.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
require __DIR__ . '/vendor/autoload.php';
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();
require __DIR__ . '/src/helpers/global-functions.php';
$protocol = isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : "http";
$url = $protocol . '://' . $_SERVER['SERVER_NAME'];
if ($_SERVER['SERVER_PORT'] != 80) {
$url .= ':' . $_SERVER['SERVER_PORT'];
}
$url .= '/';
define('URL', $url);
define("TMP", __DIR__ . '/tmp');
$loader = new Twig_Loader_Filesystem([__DIR__ . '/views', __DIR__ . '/templates']);
$twig = new Twig_Environment($loader, array(
'cache' => __DIR__ . '/cache/views',
'auto_reload' => true,
));
$config = new GeeksAreForLife\Config\Config();
$config->load(__DIR__ . '/config.json', __DIR__ . '/config-default.json');
// we will get this from the installed providers later
$providers = [];
$serviceNames = [];
foreach ($config->getValue('providers') as $provider)
{
$provider = GeeksAreForLife\AiccVideo\Providers\Factory::loadProvider($provider['namespace'], $config);
$providers[$provider->getName()] = $provider;
$serviceNames[] = $provider->getName();
}
asort($serviceNames);
$twig->addGlobal('services', $serviceNames);