|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the O2System PHP Framework package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
* |
|
8
|
|
|
* @author Steeve Andrian Salim |
|
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
|
10
|
|
|
*/ |
|
11
|
|
|
// ------------------------------------------------------------------------ |
|
12
|
|
|
|
|
13
|
|
|
if ( ! function_exists('o2system')) { |
|
14
|
|
|
/** |
|
15
|
|
|
* o2system |
|
16
|
|
|
* |
|
17
|
|
|
* Convenient shortcut for O2System Framework Instance |
|
18
|
|
|
* |
|
19
|
|
|
* @return O2System\Reactor |
|
20
|
|
|
*/ |
|
21
|
|
|
function o2system() |
|
22
|
|
|
{ |
|
23
|
|
|
return O2System\Reactor::getInstance(); |
|
24
|
|
|
} |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
// ------------------------------------------------------------------------ |
|
28
|
|
|
|
|
29
|
|
|
if ( ! function_exists('loader')) { |
|
30
|
|
|
/** |
|
31
|
|
|
* loader |
|
32
|
|
|
* |
|
33
|
|
|
* Convenient shortcut for O2System Framework Loader service. |
|
34
|
|
|
* |
|
35
|
|
|
* @return bool|O2System\Framework\Services\Loader |
|
|
|
|
|
|
36
|
|
|
*/ |
|
37
|
|
|
function loader() |
|
38
|
|
|
{ |
|
39
|
|
|
if(services()->has('loader')) { |
|
40
|
|
|
return services()->get('loader'); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return false; |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
// ------------------------------------------------------------------------ |
|
48
|
|
|
|
|
49
|
|
|
if ( ! function_exists('config')) { |
|
50
|
|
|
/** |
|
51
|
|
|
* config |
|
52
|
|
|
* |
|
53
|
|
|
* Convenient shortcut for O2System Framework Config service. |
|
54
|
|
|
* |
|
55
|
|
|
* @return O2System\Reactor\Containers\Config|\O2System\Kernel\Datastructures\Config |
|
56
|
|
|
*/ |
|
57
|
|
|
function config() |
|
58
|
|
|
{ |
|
59
|
|
|
$args = func_get_args(); |
|
60
|
|
|
|
|
61
|
|
|
if ($numArgs = count($args)) { |
|
62
|
|
|
$config = o2system()->config; |
|
63
|
|
|
|
|
64
|
|
|
if($numArgs == 1) { |
|
65
|
|
|
return call_user_func_array([&$config, 'getItem'], $args); |
|
66
|
|
|
} else { |
|
67
|
|
|
return call_user_func_array([&$config, 'loadFile'], $args); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return o2system()->config; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
// ------------------------------------------------------------------------ |
|
76
|
|
|
|
|
77
|
|
|
if ( ! function_exists('globals')) { |
|
78
|
|
|
/** |
|
79
|
|
|
* globals |
|
80
|
|
|
* |
|
81
|
|
|
* Convenient shortcut for O2System Framework globals container. |
|
82
|
|
|
* |
|
83
|
|
|
* @return mixed|O2System\Reactor\Containers\Globals |
|
84
|
|
|
*/ |
|
85
|
|
|
function globals() |
|
86
|
|
|
{ |
|
87
|
|
|
$args = func_get_args(); |
|
88
|
|
|
|
|
89
|
|
|
if (count($args)) { |
|
90
|
|
|
if (isset($GLOBALS[ $args[ 0 ] ])) { |
|
91
|
|
|
return $GLOBALS[ $args[ 0 ] ]; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
return null; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
return o2system()->globals; |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
// ------------------------------------------------------------------------ |
|
102
|
|
|
|
|
103
|
|
|
if ( ! function_exists('env')) { |
|
104
|
|
|
/** |
|
105
|
|
|
* env |
|
106
|
|
|
* |
|
107
|
|
|
* Convenient shortcut for O2System Framework environment container. |
|
108
|
|
|
* |
|
109
|
|
|
* @return mixed|O2System\Framework\Containers\Globals |
|
|
|
|
|
|
110
|
|
|
*/ |
|
111
|
|
|
function env() |
|
112
|
|
|
{ |
|
113
|
|
|
$args = func_get_args(); |
|
114
|
|
|
|
|
115
|
|
|
if (count($args)) { |
|
116
|
|
|
if (isset($_ENV[ $args[ 0 ] ])) { |
|
117
|
|
|
return $_ENV[ $args[ 0 ] ]; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
return null; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
return o2system()->environment; |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
// ------------------------------------------------------------------------ |
|
128
|
|
|
|
|
129
|
|
|
if ( ! function_exists('cache')) { |
|
130
|
|
|
/** |
|
131
|
|
|
* cache |
|
132
|
|
|
* |
|
133
|
|
|
* Convenient shortcut for O2System Framework Cache service. |
|
134
|
|
|
* |
|
135
|
|
|
* @return O2System\Framework\Services\Cache|boolean Returns FALSE if service not exists. |
|
|
|
|
|
|
136
|
|
|
*/ |
|
137
|
|
|
function cache() |
|
138
|
|
|
{ |
|
139
|
|
|
if(services()->has('cache')) { |
|
140
|
|
|
return services()->get('cache'); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
return false; |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
// ------------------------------------------------------------------------ |
|
148
|
|
|
|
|
149
|
|
|
if ( ! function_exists('database')) { |
|
150
|
|
|
/** |
|
151
|
|
|
* database |
|
152
|
|
|
* |
|
153
|
|
|
* Convenient shortcut for O2System Framework Database Connection pools. |
|
154
|
|
|
* |
|
155
|
|
|
* @return O2System\Database\Connections |
|
156
|
|
|
*/ |
|
157
|
|
|
function database() |
|
158
|
|
|
{ |
|
159
|
|
|
return models()->database; |
|
160
|
|
|
} |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
// ------------------------------------------------------------------------ |
|
164
|
|
|
|
|
165
|
|
|
if ( ! function_exists('models')) { |
|
166
|
|
|
/** |
|
167
|
|
|
* models |
|
168
|
|
|
* |
|
169
|
|
|
* Convenient shortcut for O2System Framework Models container. |
|
170
|
|
|
* |
|
171
|
|
|
* @return O2System\Framework\Containers\Models|O2System\Framework\Models\Sql\Model|O2System\Framework\Models\NoSql\Model |
|
|
|
|
|
|
172
|
|
|
*/ |
|
173
|
|
|
function models() |
|
174
|
|
|
{ |
|
175
|
|
|
$args = func_get_args(); |
|
176
|
|
|
|
|
177
|
|
|
if (count($args)) { |
|
178
|
|
|
return o2system()->models->get($args[ 0 ]); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
return o2system()->models; |
|
|
|
|
|
|
182
|
|
|
} |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
// ------------------------------------------------------------------------ |
|
186
|
|
|
|
|
187
|
|
|
if ( ! function_exists('router')) { |
|
188
|
|
|
/** |
|
189
|
|
|
* router |
|
190
|
|
|
* |
|
191
|
|
|
* Convenient shortcut for O2System Framework Router service. |
|
192
|
|
|
* |
|
193
|
|
|
* @return bool|O2System\Framework\Http\Router|O2System\Framework\Cli\Router |
|
|
|
|
|
|
194
|
|
|
*/ |
|
195
|
|
|
function router() |
|
196
|
|
|
{ |
|
197
|
|
|
if(services()->has('router')) { |
|
198
|
|
|
return services()->get('router'); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
return false; |
|
202
|
|
|
} |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
// ------------------------------------------------------------------------ |
|
206
|
|
|
|
|
207
|
|
|
if ( ! function_exists('session')) { |
|
208
|
|
|
/** |
|
209
|
|
|
* session |
|
210
|
|
|
* |
|
211
|
|
|
* Convenient shortcut for O2System Framework Session service. |
|
212
|
|
|
* |
|
213
|
|
|
* @return mixed|O2System\Session |
|
214
|
|
|
*/ |
|
215
|
|
|
function session() |
|
216
|
|
|
{ |
|
217
|
|
|
$args = func_get_args(); |
|
218
|
|
|
|
|
219
|
|
|
if (count($args)) { |
|
220
|
|
|
if(isset($_SESSION[ $args[0] ])) { |
|
221
|
|
|
return $_SESSION[ $args[0] ]; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
return null; |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
return services('session'); |
|
228
|
|
|
} |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
// ------------------------------------------------------------------------ |
|
232
|
|
|
|
|
233
|
|
|
if ( ! function_exists('middleware')) { |
|
234
|
|
|
/** |
|
235
|
|
|
* O2System |
|
236
|
|
|
* |
|
237
|
|
|
* Convenient shortcut for O2System Framework Http Middleware service. |
|
238
|
|
|
* |
|
239
|
|
|
* @return bool|O2System\Framework\Http\Middleware |
|
|
|
|
|
|
240
|
|
|
*/ |
|
241
|
|
|
function middleware() |
|
242
|
|
|
{ |
|
243
|
|
|
if(services()->has('middleware')) { |
|
244
|
|
|
return services()->get('middleware'); |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
return false; |
|
248
|
|
|
} |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
// ------------------------------------------------------------------------ |
|
252
|
|
|
|
|
253
|
|
|
if ( ! function_exists('controller')) { |
|
254
|
|
|
/** |
|
255
|
|
|
* controller |
|
256
|
|
|
* |
|
257
|
|
|
* Convenient shortcut for O2System Framework Controller service. |
|
258
|
|
|
* |
|
259
|
|
|
* @return O2System\Framework\Http\Controller|bool |
|
|
|
|
|
|
260
|
|
|
*/ |
|
261
|
|
|
function controller() |
|
262
|
|
|
{ |
|
263
|
|
|
if(services()->has('controller')) { |
|
264
|
|
|
$args = func_get_args(); |
|
265
|
|
|
|
|
266
|
|
|
if (count($args)) { |
|
267
|
|
|
$controller = services()->get('controller'); |
|
268
|
|
|
|
|
269
|
|
|
return call_user_func_array([&$controller, '__call'], $args); |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
return services('controller'); |
|
|
|
|
|
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
return false; |
|
276
|
|
|
} |
|
277
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths