-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
94 lines (86 loc) · 2.22 KB
/
functions.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
<?php
use Illuminate\Config\Repository as ConfigRepository;
if (! function_exists('join_path')) {
/**
* Join paths
*
*
* @return string
*/
function join_path($basePath, $path = '')
{
return $basePath.(
$path != '' ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : ''
);
}
}
if (! function_exists('get_base_path')) {
/**
* Get App Base Path
*
*
* @return string
*/
function get_base_path($path = '')
{
if (function_exists('base_path')) {
return base_path($path);
} else {
return dirname(__DIR__, 4).($path != '' ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : '');
}
}
}
if (! function_exists('get_config_path')) {
/**
* Get the configuration path.
*
* @param string $path
* @return string
*/
function get_config_path($path = '')
{
if (function_exists('base_path')) {
return join_path(base_path('config'), $path);
} else {
return join_path(get_base_path('config'), $path);
}
}
}
if (! function_exists('get_config')) {
/**
* Get / set the specified configuration value.
*
* If an array is passed as the key, we will assume you want to set an array of values.
*
* @param array|string|null $key
* @param mixed|null $default
* @return mixed|ConfigRepository|void
*/
function get_config($key = null, $default = null)
{
if (function_exists('config')) {
return config($key, $default);
} else {
if (is_null($key)) {
return new ConfigRepository();
}
if (is_array($key)) {
return (new ConfigRepository(require __DIR__.'/../config/config.php'))->set($key);
}
return (new ConfigRepository(require __DIR__.'/../config/config.php'))->get($key, $default);
}
}
}
if (! function_exists('print_data')) {
/**
* @param mixed $data
*/
function print_data(...$data): void
{
foreach ($data as $obj) {
echo '<pre>';
print_r($obj);
echo "</pre>\n";
}
}
}