-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
paths.php
113 lines (97 loc) · 3.1 KB
/
paths.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
106
107
108
109
110
111
112
113
<?php
defined('DS') or exit('No direct access.');
$paths = [];
// --------------------------------------------------------------
// Path ke direktori paket default.
// --------------------------------------------------------------
$paths['app'] = 'application';
// --------------------------------------------------------------
// Path ke file key.
// --------------------------------------------------------------
$paths['rakit_key'] = 'key.php';
// --------------------------------------------------------------
// Path ke direktori sistem.
// --------------------------------------------------------------
$paths['system'] = 'system';
// --------------------------------------------------------------
// Path ke direktori utama paket.
// --------------------------------------------------------------
$paths['package'] = 'packages';
// --------------------------------------------------------------
// Path ke direktori storage.
// --------------------------------------------------------------
$paths['storage'] = 'storage';
// --------------------------------------------------------------
// Path ke direktori aset.
// --------------------------------------------------------------
$paths['assets'] = 'assets';
// --------------------------------------------------------------
// Ubah direktori kerja ke direktori root.
// --------------------------------------------------------------
chdir(__DIR__);
// --------------------------------------------------------------
// Definisikan path ke base direktori.
// --------------------------------------------------------------
$GLOBALS['rakit_paths']['base'] = __DIR__ . DS;
// --------------------------------------------------------------
// Defininisikan konstanta lain yang belum ada.
// --------------------------------------------------------------
foreach ($paths as $name => $path) {
if (!isset($GLOBALS['rakit_paths'][$name])) {
$GLOBALS['rakit_paths'][$name] = ('rakit_key' === $name)
? $GLOBALS['rakit_paths']['base'] . $path
: realpath($path) . DS;
}
}
/**
* Fungsi global untuk akses path.
*
* <code>
*
* $storage = path('storage');
*
* </code>
*
* @param string $path
*
* @return string
*/
function path($path)
{
return $GLOBALS['rakit_paths'][$path];
}
/**
* Fungsi global untuk setting path.
*
* @param string $path
* @param string $value
*/
function set_path($path, $value)
{
$GLOBALS['rakit_paths'][$path] = $value;
}
// --------------------------------------------------------------
// Polyfill untuk atribut #[\ReturnTypeWillChange].
// --------------------------------------------------------------
if (PHP_VERSION_ID < 80000) {
final class Attribute
{
const TARGET_CLASS = 1;
const TARGET_FUNCTION = 2;
const TARGET_METHOD = 4;
const TARGET_PROPERTY = 8;
const TARGET_CLASS_CONSTANT = 16;
const TARGET_PARAMETER = 32;
const TARGET_ALL = 63;
}
}
if (PHP_VERSION_ID < 80100) {
#[Attribute(Attribute::TARGET_METHOD)]
final class ReturnTypeWillChange
{
public function __construct()
{
// ..
}
}
}