blob: b3679879fee7c51c71eded61586bd1bd38e70e94 (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
<?php
/**
* PHPPgAdmin6
*/
use PHPPgAdmin\Core\ContainerUtils;
use Slim\App;
use Slim\Http\Request;
use Slim\Http\Response;
\defined('BASE_PATH') || \define('BASE_PATH', \dirname(__DIR__));
/**
* PHPPgAdmin 6.1.3.
*/
function getAppInstance(): App
{
$subfolder = '';
// Check to see if the configuration file exists, if not, explain
if (!\file_exists(\dirname(__DIR__) . '/config.inc.php')) {
exit('Configuration error: Copy config.inc.php-dist to config.inc.php and edit appropriately.');
}
$conf = [];
include_once \dirname(__DIR__) . '/config.inc.php';
if (isset($conf['subfolder']) && \is_string($conf['subfolder'])) {
$subfolder = $conf['subfolder'];
} elseif (\PHP_SAPI === 'cli-server' || \PHP_SAPI === 'cli') {
$subfolder = '/index.php';
} elseif (isset($_SERVER['DOCUMENT_ROOT'])) {
$subfolder = \str_replace(
$_SERVER['DOCUMENT_ROOT'],
'',
\dirname(__DIR__)
);
}
$conf['subfolder'] = $subfolder;
$conf['debugmode'] = (!isset($conf['debugmode'])) ? false : (bool) ($conf['debugmode']);
if ($conf['debugmode']) {
\ini_set('display_startup_errors', 'On');
\ini_set('opcache.revalidate_freq', '0');
\error_reporting(\E_ALL);
if (\array_key_exists('register_debuggers', $conf) && \is_callable($conf['register_debuggers'])) {
$conf['register_debuggers']();
}
}
$conf['BASE_PATH'] = BASE_PATH;
$conf['theme_path'] = BASE_PATH . '/assets/themes';
\defined('IN_TEST') || \define('IN_TEST', false);
$conf['IN_TEST'] = IN_TEST;
// Fetch App and DI Container
$app = ContainerUtils::getAppInstance($conf);
return $app;
}
function containerInstance(): ContainerUtils
{
$app = getAppInstance();
$container = $app->getContainer();
if (!$container instanceof ContainerUtils) {
\trigger_error('App Container must be an instance of \\Slim\\Container', \E_USER_ERROR);
}
return $container;
}
function requestInstance(): Request
{
return \containerInstance()->request;
}
function responseInstance(): Response
{
return \containerInstance()->response;
}
|