-
Notifications
You must be signed in to change notification settings - Fork 0
/
defines.php
executable file
·107 lines (71 loc) · 2.33 KB
/
defines.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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
define("BASEDIR", __DIR__);
define("DS", "/");
define("JSON_DIR", BASEDIR . DS . "shadowapp" . DS . "sh_db");
define("MIDDLEWARE_DIR", BASEDIR . DS . "shadowapp" . DS . "Components" . DS . "Middlewares");
define("COMMANDS_DIR", BASEDIR . DS . "shadowapp" . DS . "Components" . DS . 'Commanding' . DS . "Commands" . DS);
define("COMMAND_HANDLER_DIR", BASEDIR . DS . "shadowapp" . DS . "Components" . DS . 'Commanding' . DS . "CommandHandlers" . DS);
define("CONFIG_DIR", BASEDIR . DS . 'shadowapp' . DS . 'config' . DS);
define("EVENT_LISTENERS_DIR", BASEDIR . DS . 'shadowapp' . DS . 'Components' . DS . 'Eventing' . DS . 'Listeners' . DS);
if (!function_exists('setDir')) {
function setDir($dirPath)
{
$dirList = scandir($dirPath);
for ($i = 0; $i < count($dirList); $i++) {
if ($i > 1) {
require_once $dirPath . $dirList[$i];
}
}
}
}
if (!function_exists('parr')) {
function parr($Value)
{
echo "<pre>" . print_r($Value, 1) . "</pre>";
}
}
if (!function_exists('shcol')) {
function shcol($Key, $Collection, $Default = '')
{
$Keys = explode('.', $Key);
$Data = $Collection;
foreach ($Keys as $kkk) {
if (is_object($Data)) {
$Data = (array) $Data;
}
if (!isset($Data[$kkk])) {
return $Default;
}
$Data = $Data[$kkk];
}
return $Data;
}
}
if (!function_exists('response')) {
function response()
{
return new Shadowapp\Sys\Http\Response;
}
}
if (!function_exists('baseurl')) {
function baseurl()
{
$baseFolder = ( class_exists(\Shadowapp\Sys\Config::class) ) ? '/' . shcol('base_folder', (new \Shadowapp\Sys\Config)->get()) : '';
$http = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http';
return $http . '://' . $_SERVER['HTTP_HOST'] . $baseFolder;
}
}
if (!function_exists('basePath')) {
function basePath()
{
return file_exists(__DIR__ . DS . 'shadowapp/') ?
__DIR__ . DS . 'shadowapp/' :
'';
}
}
if (!function_exists('route')) {
function route(string $routeName, array $args = [])
{
return \Shadowapp\Sys\Routing\Router::uri($routeName, $args);
}
}