1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Blitz PHP framework. |
5
|
|
|
* |
6
|
|
|
* (c) 2022 Dimitri Sitchet Tomkeu <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view |
9
|
|
|
* the LICENSE file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
if (! function_exists('css_path')) { |
13
|
|
|
/** |
14
|
|
|
* CSS PATH |
15
|
|
|
* |
16
|
|
|
* Renvoie le chemin absolu d'un fichier css. |
17
|
|
|
* |
18
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
19
|
|
|
*/ |
20
|
|
|
function css_path(string $name = ''): string |
21
|
|
|
{ |
22
|
|
|
if ($name !== '' && $name !== '0') { |
23
|
|
|
$name = ltrim($name, '/\\'); |
24
|
|
|
|
25
|
|
|
$pathinfo = pathinfo($name, PATHINFO_EXTENSION); |
26
|
|
|
if ($pathinfo === '' || $pathinfo === '0') { |
27
|
|
|
$name .= '.css'; |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
return WEBROOT . 'css' . DS . str_replace('/', DS, $name); |
|
|
|
|
32
|
|
|
} |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
if (! function_exists('js_path')) { |
36
|
|
|
/** |
37
|
|
|
* JS PATH |
38
|
|
|
* |
39
|
|
|
* Renvoie le chemin absolu d'un fichier js. |
40
|
|
|
* |
41
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
42
|
|
|
*/ |
43
|
|
|
function js_path(string $name = ''): string |
44
|
|
|
{ |
45
|
|
|
if ($name !== '' && $name !== '0') { |
46
|
|
|
$name = ltrim($name, '/\\'); |
47
|
|
|
|
48
|
|
|
$pathinfo = pathinfo($name, PATHINFO_EXTENSION); |
49
|
|
|
if ($pathinfo === '' || $pathinfo === '0') { |
50
|
|
|
$name .= '.js'; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return WEBROOT . 'js' . DS . str_replace('/', DS, $name); |
|
|
|
|
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
if (! function_exists('lib_path')) { |
59
|
|
|
/** |
60
|
|
|
* LIB PATH |
61
|
|
|
* |
62
|
|
|
* Renvoie le chemin absolu d'un fichier d'une librairie |
63
|
|
|
* |
64
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
65
|
|
|
*/ |
66
|
|
|
function lib_path(string $name = ''): string |
67
|
|
|
{ |
68
|
|
|
if ($name !== '' && $name !== '0') { |
69
|
|
|
$name = ltrim($name, '/\\'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return WEBROOT . 'lib' . DS . str_replace('/', DS, $name); |
|
|
|
|
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
if (! function_exists('less_path')) { |
77
|
|
|
/** |
78
|
|
|
* LESS PATH |
79
|
|
|
* |
80
|
|
|
* Renvoie le chemin absolu d'un fichier less. |
81
|
|
|
* |
82
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
83
|
|
|
*/ |
84
|
|
|
function less_path(string $name = ''): string |
85
|
|
|
{ |
86
|
|
|
if ($name !== '' && $name !== '0') { |
87
|
|
|
$name = ltrim($name, '/\\'); |
88
|
|
|
|
89
|
|
|
$pathinfo = pathinfo($name, PATHINFO_EXTENSION); |
90
|
|
|
if ($pathinfo === '' || $pathinfo === '0') { |
91
|
|
|
$name .= '.less'; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
return WEBROOT . 'less' . DS . str_replace('/', DS, $name); |
|
|
|
|
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
if (! function_exists('img_path')) { |
100
|
|
|
/** |
101
|
|
|
* IMG PATH |
102
|
|
|
* |
103
|
|
|
* Renvoie le chemin absolu d'une image |
104
|
|
|
* |
105
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
106
|
|
|
*/ |
107
|
|
|
function img_path(string $name = ''): string |
108
|
|
|
{ |
109
|
|
|
if ($name !== '' && $name !== '0') { |
110
|
|
|
$name = ltrim($name, '/\\'); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
return WEBROOT . 'img' . DS . str_replace('/', DS, $name); |
|
|
|
|
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
if (! function_exists('docs_path')) { |
118
|
|
|
/** |
119
|
|
|
* DOCS PATH |
120
|
|
|
* |
121
|
|
|
* Renvoie le chemin absolu d'un document |
122
|
|
|
* |
123
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
124
|
|
|
*/ |
125
|
|
|
function docs_path(string $name = ''): string |
126
|
|
|
{ |
127
|
|
|
if ($name !== '' && $name !== '0') { |
128
|
|
|
$name = ltrim($name, '/\\'); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
return WEBROOT . 'docs' . DS . str_replace('/', DS, $name); |
|
|
|
|
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
if (! function_exists('video_path')) { |
136
|
|
|
/** |
137
|
|
|
* VIDEO PATH |
138
|
|
|
* |
139
|
|
|
* Renvoie le chemin absolu d'une vidéo |
140
|
|
|
* |
141
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
142
|
|
|
*/ |
143
|
|
|
function video_path(string $name = ''): string |
144
|
|
|
{ |
145
|
|
|
if ($name !== '' && $name !== '0') { |
146
|
|
|
$name = ltrim($name, '/\\'); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
return WEBROOT . 'videos' . DS . str_replace('/', DS, $name); |
|
|
|
|
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
if (! function_exists('public_path')) { |
154
|
|
|
/** |
155
|
|
|
* PUBLIC PATH |
156
|
|
|
* |
157
|
|
|
* Renvoie le chemin absolu du dossier public |
158
|
|
|
* |
159
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
160
|
|
|
*/ |
161
|
|
|
function public_path(string $name = ''): string |
162
|
|
|
{ |
163
|
|
|
if ($name !== '' && $name !== '0') { |
164
|
2 |
|
$name = ltrim($name, '/\\'); |
165
|
|
|
} |
166
|
|
|
|
167
|
2 |
|
return WEBROOT . str_replace('/', DS, $name); |
|
|
|
|
168
|
|
|
} |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
if (! function_exists('root_path')) { |
172
|
|
|
/** |
173
|
|
|
* ROOT PATH |
174
|
|
|
* |
175
|
|
|
* Renvoie le chemin absolu du dossier racine |
176
|
|
|
* |
177
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
178
|
|
|
*/ |
179
|
|
|
function root_path(string $name = ''): string |
180
|
|
|
{ |
181
|
|
|
if ($name !== '' && $name !== '0') { |
182
|
|
|
$name = ltrim($name, '/\\'); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
return ROOTPATH . str_replace('/', DS, $name); |
186
|
|
|
} |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
if (! function_exists('base_path')) { |
190
|
|
|
/** |
191
|
|
|
* BASE PATH |
192
|
|
|
* |
193
|
|
|
* Renvoie le chemin absolu du dossier de base |
194
|
|
|
* |
195
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
196
|
|
|
*/ |
197
|
|
|
function base_path(string $name = ''): string |
198
|
|
|
{ |
199
|
|
|
if ($name !== '' && $name !== '0') { |
200
|
|
|
$name = ltrim($name, '/\\'); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
return BASEPATH . str_replace('/', DS, $name); |
204
|
|
|
} |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
if (! function_exists('resource_path')) { |
208
|
|
|
/** |
209
|
|
|
* BASE RESOURCE PATH |
210
|
|
|
* |
211
|
|
|
* Renvoie le chemin absolu d'un fichier ressource de base |
212
|
|
|
* |
213
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
214
|
|
|
*/ |
215
|
|
|
function resource_path(string $name = ''): string |
216
|
|
|
{ |
217
|
|
|
if ($name !== '' && $name !== '0') { |
218
|
|
|
$name = ltrim($name, '/\\'); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
return RESOURCE_PATH . str_replace('/', DS, $name); |
222
|
|
|
} |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
if (! function_exists('class_path')) { |
226
|
|
|
/** |
227
|
|
|
* CLASS PATH |
228
|
|
|
* |
229
|
|
|
* Renvoie le chemin absolu d'une classe applicative |
230
|
|
|
* |
231
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
232
|
|
|
*/ |
233
|
|
|
function class_path(string $name = ''): string |
234
|
|
|
{ |
235
|
|
|
if ($name !== '' && $name !== '0') { |
236
|
|
|
$name = ltrim($name, '/\\'); |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
return APP_PATH . 'class' . DS . str_replace('/', DS, $name); |
240
|
|
|
} |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
if (! function_exists('config_path')) { |
244
|
|
|
/** |
245
|
|
|
* CONFIG PATH |
246
|
|
|
* |
247
|
|
|
* Renvoie le chemin absolu d'un fichier de configuration |
248
|
|
|
* |
249
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
250
|
|
|
*/ |
251
|
|
|
function config_path(string $name = ''): string |
252
|
|
|
{ |
253
|
|
|
if ($name !== '' && $name !== '0') { |
254
|
4 |
|
$name = ltrim($name, '/\\'); |
255
|
|
|
|
256
|
4 |
|
$pathinfo = pathinfo($name, PATHINFO_EXTENSION); |
257
|
|
|
if ($pathinfo === '' || $pathinfo === '0') { |
258
|
4 |
|
$name .= '.php'; |
259
|
|
|
} |
260
|
|
|
} |
261
|
|
|
|
262
|
4 |
|
return CONFIG_PATH . str_replace('/', DS, $name); |
263
|
|
|
} |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
if (! function_exists('controller_path')) { |
267
|
|
|
/** |
268
|
|
|
* CONTROLLER PATH |
269
|
|
|
* |
270
|
|
|
* Renvoie le chemin absolu d'un contrôleur |
271
|
|
|
* |
272
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
273
|
|
|
* @param bool $only specifie si on veut seulement les contrôleurs (fichier php ayant le suffixe Controller) |
274
|
|
|
*/ |
275
|
|
|
function controller_path(string $name = '', bool $only = true): string |
276
|
|
|
{ |
277
|
|
|
if ($name !== '' && $name !== '0') { |
278
|
|
|
$name = ltrim($name, '/\\'); |
279
|
|
|
|
280
|
|
|
if ($only === true && ! preg_match('#Controller\.php$#', $name)) { |
281
|
|
|
$name = ucfirst(strtolower($name)) . 'Controller.php'; |
282
|
|
|
} |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
return CONTROLLER_PATH . str_replace('/', DS, $name); |
286
|
|
|
} |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
if (! function_exists('entity_path')) { |
290
|
|
|
/** |
291
|
|
|
* ENTITY PATH |
292
|
|
|
* |
293
|
|
|
* Renvoie le chemin absolu d'une entité |
294
|
|
|
* |
295
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
296
|
|
|
* @param bool $only specifie si on veut seulement les fichiers d'entité (fichiers php ayant le suffixe Entity) |
297
|
|
|
*/ |
298
|
|
|
function entity_path(string $name = '', bool $only = true): string |
299
|
|
|
{ |
300
|
|
|
if ($name !== '' && $name !== '0') { |
301
|
|
|
$name = ltrim($name, '/\\'); |
302
|
|
|
|
303
|
|
|
if ($only === true && ! preg_match('#Entity\.php$#', $name)) { |
304
|
|
|
$name = ucfirst($name) . 'Entity.php'; |
305
|
|
|
} |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
return ENTITY_PATH . str_replace('/', DS, $name); |
309
|
|
|
} |
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
if (! function_exists('helper_path')) { |
313
|
|
|
/** |
314
|
|
|
* HELPER PATH |
315
|
|
|
* |
316
|
|
|
* Renvoie le chemin absolu d'un helper |
317
|
|
|
* |
318
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
319
|
|
|
* @param bool $system specifie s'il s'agit des helpers systeme ou applicatif |
320
|
|
|
*/ |
321
|
|
|
function helper_path(string $name = '', bool $system = false): string |
322
|
|
|
{ |
323
|
|
|
if ($name !== '' && $name !== '0') { |
324
|
|
|
$name = ltrim($name, '/\\'); |
325
|
|
|
|
326
|
|
|
$pathinfo = pathinfo($name, PATHINFO_EXTENSION); |
327
|
|
|
if ($pathinfo === '' || $pathinfo === '0') { |
328
|
|
|
$name .= '.php'; |
329
|
|
|
} |
330
|
|
|
} |
331
|
|
|
if ($system === true) { |
332
|
|
|
return SYST_PATH . 'helpers' . DS . str_replace('/', DS, $name); |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
return APP_PATH . 'helpers' . DS . str_replace('/', DS, $name); |
336
|
|
|
} |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
if (! function_exists('library_path')) { |
340
|
|
|
/** |
341
|
|
|
* LIBRARY PATH |
342
|
|
|
* |
343
|
|
|
* Renvoie le chemin absolu d'une librairie |
344
|
|
|
* |
345
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
346
|
|
|
* @param bool $system specifie s'il s'agit des librairies systeme ou applicatif |
347
|
|
|
*/ |
348
|
|
|
function library_path(string $name = '', bool $system = false): string |
349
|
|
|
{ |
350
|
|
|
if ($name !== '' && $name !== '0') { |
351
|
|
|
$name = ltrim($name, '/\\'); |
352
|
|
|
|
353
|
|
|
$pathinfo = pathinfo($name, PATHINFO_EXTENSION); |
354
|
|
|
if ($pathinfo === '' || $pathinfo === '0') { |
355
|
|
|
$name .= '.php'; |
356
|
|
|
} |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
if ($system === true) { |
360
|
|
|
return SYST_PATH . 'libraries' . DS . str_replace('/', DS, $name); |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
return APP_PATH . 'libraries' . DS . str_replace('/', DS, $name); |
364
|
|
|
} |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
if (! function_exists('middleware_path')) { |
368
|
|
|
/** |
369
|
|
|
* MIDDLEWARE PATH |
370
|
|
|
* |
371
|
|
|
* Renvoie le chemin absolu d'un middleware |
372
|
|
|
* |
373
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
374
|
|
|
* @param bool $system specifie s'il s'agit des middlewares systeme ou applicatif |
375
|
|
|
* @param bool $only specifie si on veut seulement les middlewares (fichiers php ayant le suffixe Middleware) |
376
|
|
|
*/ |
377
|
|
|
function middleware_path(string $name = '', bool $system = false, bool $only = true): string |
378
|
|
|
{ |
379
|
|
|
if ($name !== '' && $name !== '0') { |
380
|
|
|
$name = ltrim($name, '/\\'); |
381
|
|
|
|
382
|
|
|
if ($only === true && ! preg_match('#Middleware\.php$#', $name)) { |
383
|
|
|
$name = ucfirst($name) . 'Middleware.php'; |
384
|
|
|
} |
385
|
|
|
} |
386
|
|
|
if ($system === true) { |
387
|
|
|
return SYST_PATH . 'middlewares' . DS . str_replace('/', DS, $name); |
388
|
|
|
} |
389
|
|
|
|
390
|
|
|
return APP_PATH . 'middlewares' . DS . str_replace('/', DS, $name); |
391
|
|
|
} |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
if (! function_exists('model_path')) { |
395
|
|
|
/** |
396
|
|
|
* MODEL PATH |
397
|
|
|
* |
398
|
|
|
* Renvoie le chemin absolu d'un modèle |
399
|
|
|
* |
400
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
401
|
|
|
* @param bool $only specifie si on veut seulement les modèles (fichiers php ayant le suffixe Model) |
402
|
|
|
*/ |
403
|
|
|
function model_path(string $name = '', bool $only = true): string |
404
|
|
|
{ |
405
|
|
|
if ($name !== '' && $name !== '0') { |
406
|
|
|
$name = ltrim($name, '/\\'); |
407
|
|
|
|
408
|
|
|
if ($only === true && ! preg_match('#Model\.php$#', $name)) { |
409
|
|
|
$name = ucfirst(strtolower($name)) . 'Model.php'; |
410
|
|
|
} |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
return MODEL_PATH . str_replace('/', DS, $name); |
414
|
|
|
} |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
if (! function_exists('app_resource_path')) { |
418
|
|
|
/** |
419
|
|
|
* APP RESOURCE PATH |
420
|
|
|
* |
421
|
|
|
* Renvoie le chemin absolu d'un fichier ressource applicative |
422
|
|
|
* |
423
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
424
|
|
|
*/ |
425
|
|
|
function app_resource_path(string $name = ''): string |
426
|
|
|
{ |
427
|
|
|
if ($name !== '' && $name !== '0') { |
428
|
|
|
$name = ltrim($name, '/\\'); |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
return APP_RESOURCE_PATH . str_replace('/', DS, $name); |
432
|
|
|
} |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
if (! function_exists('migration_path')) { |
436
|
|
|
/** |
437
|
|
|
* MIGRATION PATH |
438
|
|
|
* |
439
|
|
|
* Renvoie le chemin absolu d'un fichier de migration |
440
|
|
|
* |
441
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
442
|
|
|
*/ |
443
|
|
|
function migration_path(string $name = ''): string |
444
|
|
|
{ |
445
|
|
|
if ($name !== '' && $name !== '0') { |
446
|
|
|
$name = ltrim($name, '/\\'); |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
return DB_MIGRATION_PATH . str_replace('/', DS, $name); |
450
|
|
|
} |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
if (! function_exists('seed_path')) { |
454
|
|
|
/** |
455
|
|
|
* SEED PATH |
456
|
|
|
* |
457
|
|
|
* Renvoie le chemin absolu d'un fichier de seed |
458
|
|
|
* |
459
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
460
|
|
|
*/ |
461
|
|
|
function seed_path(string $name = ''): string |
462
|
|
|
{ |
463
|
|
|
if ($name !== '' && $name !== '0') { |
464
|
|
|
$name = ltrim($name, '/\\'); |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
return DB_SEED_PATH . str_replace('/', DS, $name); |
468
|
|
|
} |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
if (! function_exists('lang_path')) { |
472
|
|
|
/** |
473
|
|
|
* LANG PATH |
474
|
|
|
* |
475
|
|
|
* Renvoie le chemin absolu d'un fichier de langue |
476
|
|
|
* |
477
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
478
|
|
|
* @param bool $system specifie s'il s'agit des langues systeme ou applicatif |
479
|
|
|
*/ |
480
|
|
|
function lang_path(string $name = '', bool $system = false): string |
481
|
|
|
{ |
482
|
|
|
if ($name !== '' && $name !== '0') { |
483
|
|
|
$name = ltrim($name, '/\\'); |
484
|
|
|
} |
485
|
|
|
if ($system === true) { |
486
|
|
|
return SYST_PATH . 'constants' . DS . 'lang' . DS . str_replace('/', DS, $name); |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
return RESOURCE_PATH . 'lang' . DS . str_replace('/', DS, $name); |
490
|
|
|
} |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
if (! function_exists('service_path')) { |
494
|
|
|
/** |
495
|
|
|
* SERVICE PATH |
496
|
|
|
* |
497
|
|
|
* Renvoie le chemin absolu d'un service |
498
|
|
|
* |
499
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
500
|
|
|
* @param bool $only specifie si on veut seulement les services (fichier php ayant le suffixe Service) |
501
|
|
|
*/ |
502
|
|
|
function service_path(string $name = '', bool $only = true): string |
503
|
|
|
{ |
504
|
|
|
if ($name !== '' && $name !== '0') { |
505
|
|
|
$name = ltrim($name, '/\\'); |
506
|
|
|
|
507
|
|
|
if ($only === true && ! preg_match('#Service\.php$#', $name)) { |
508
|
|
|
$name = ucfirst($name) . 'Service.php'; |
509
|
|
|
} |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
return SERVICE_PATH . str_replace('/', DS, $name); |
513
|
|
|
} |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
if (! function_exists('view_path')) { |
517
|
|
|
/** |
518
|
|
|
* VIEW PATH |
519
|
|
|
* |
520
|
|
|
* Renvoie le chemin absolu d'une vue |
521
|
|
|
* |
522
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
523
|
|
|
*/ |
524
|
|
|
function view_path(string $name = ''): string |
525
|
|
|
{ |
526
|
|
|
if ($name !== '' && $name !== '0') { |
527
|
|
|
$name = ltrim($name, '/\\'); |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
return VIEW_PATH . str_replace('/', DS, $name); |
531
|
|
|
} |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
if (! function_exists('layout_path')) { |
535
|
|
|
/** |
536
|
|
|
* LAYOUT PATH |
537
|
|
|
* |
538
|
|
|
* Renvoie le chemin absolu d'un layout |
539
|
|
|
* |
540
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
541
|
|
|
*/ |
542
|
|
|
function layout_path(string $name = ''): string |
543
|
|
|
{ |
544
|
|
|
if ($name !== '' && $name !== '0') { |
545
|
|
|
$name = ltrim($name, '/\\'); |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
return LAYOUT_PATH . str_replace('/', DS, $name); |
549
|
|
|
} |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
if (! function_exists('partial_path')) { |
553
|
|
|
/** |
554
|
|
|
* PARTIAL PATH |
555
|
|
|
* |
556
|
|
|
* Renvoie le chemin absolu d'une partie de vue |
557
|
|
|
* |
558
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
559
|
|
|
*/ |
560
|
|
|
function partial_path(string $name = ''): string |
561
|
|
|
{ |
562
|
|
|
if ($name !== '' && $name !== '0') { |
563
|
|
|
$name = ltrim($name, '/\\'); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
return VIEW_PATH . 'partials' . DS . str_replace('/', DS, $name); |
567
|
|
|
} |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
if (! function_exists('app_path')) { |
571
|
|
|
/** |
572
|
|
|
* APP PATH |
573
|
|
|
* |
574
|
|
|
* Renvoie le chemin absolu d'un fichier du dossier app |
575
|
|
|
* |
576
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
577
|
|
|
*/ |
578
|
|
|
function app_path(string $name = ''): string |
579
|
|
|
{ |
580
|
|
|
if ($name !== '' && $name !== '0') { |
581
|
|
|
$name = ltrim($name, '/\\'); |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
return APP_PATH . str_replace('/', DS, $name); |
585
|
|
|
} |
586
|
|
|
} |
587
|
|
|
|
588
|
|
|
if (! function_exists('cache_path')) { |
589
|
|
|
/** |
590
|
|
|
* CACHE PATH |
591
|
|
|
* |
592
|
|
|
* Renvoie le chemin absolu d'un fichier mis en cache |
593
|
|
|
* |
594
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
595
|
|
|
*/ |
596
|
|
|
function cache_path(string $name = ''): string |
597
|
|
|
{ |
598
|
|
|
if ($name !== '' && $name !== '0') { |
599
|
2 |
|
$name = ltrim($name, '/\\'); |
600
|
|
|
} |
601
|
|
|
|
602
|
2 |
|
return VIEW_CACHE_PATH . str_replace('/', DS, $name); |
603
|
|
|
} |
604
|
|
|
} |
605
|
|
|
|
606
|
|
|
if (! function_exists('dump_path')) { |
607
|
|
|
/** |
608
|
|
|
* DUMP PATH |
609
|
|
|
* |
610
|
|
|
* Renvoie le chemin absolu d'un fichier de sauvegarde (dump) de la base de donnees |
611
|
|
|
* |
612
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
613
|
|
|
*/ |
614
|
|
|
function dump_path(string $name = ''): string |
615
|
|
|
{ |
616
|
|
|
if ($name !== '' && $name !== '0') { |
617
|
|
|
$name = ltrim($name, '/\\'); |
618
|
|
|
} |
619
|
|
|
|
620
|
|
|
return DB_DUMP_PATH . str_replace('/', DS, $name); |
621
|
|
|
} |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
if (! function_exists('storage_path')) { |
625
|
|
|
/** |
626
|
|
|
* STORAGE PATH |
627
|
|
|
* |
628
|
|
|
* Renvoie le chemin absolu d'un fichier du dossier storage |
629
|
|
|
* |
630
|
|
|
* @param string $name nom du fichier dont on veut avoir le chemin |
631
|
|
|
*/ |
632
|
|
|
function storage_path(string $name = ''): string |
633
|
|
|
{ |
634
|
|
|
if ($name !== '' && $name !== '0') { |
635
|
2 |
|
$name = ltrim($name, '/\\'); |
636
|
|
|
} |
637
|
|
|
|
638
|
2 |
|
return STORAGE_PATH . str_replace('/', DS, $name); |
639
|
|
|
} |
640
|
|
|
} |
641
|
|
|
|
642
|
|
|
if (! function_exists('css_exist')) { |
643
|
|
|
/** |
644
|
|
|
* CSS EXIST |
645
|
|
|
* |
646
|
|
|
* Verifie si un fichier css ou un sous dossier du repertoire /public/css existe |
647
|
|
|
* |
648
|
|
|
* @param string $name nom du fichier dont on veut verifier |
649
|
|
|
*/ |
650
|
|
|
function css_exist(string $name = ''): bool |
651
|
|
|
{ |
652
|
|
|
return file_exists(css_path($name)); |
653
|
|
|
} |
654
|
|
|
} |
655
|
|
|
|
656
|
|
|
if (! function_exists('js_exist')) { |
657
|
|
|
/** |
658
|
|
|
* JS EXIST |
659
|
|
|
* |
660
|
|
|
* Verifie si un fichier js ou un sous dossier du repertoire /public/js existe |
661
|
|
|
* |
662
|
|
|
* @param string $name nom du fichier dont on veut verifier |
663
|
|
|
*/ |
664
|
|
|
function js_exist(string $name = ''): bool |
665
|
|
|
{ |
666
|
|
|
return file_exists(js_path($name)); |
667
|
|
|
} |
668
|
|
|
} |
669
|
|
|
|
670
|
|
|
if (! function_exists('lib_exist')) { |
671
|
|
|
/** |
672
|
|
|
* LIB EXIST |
673
|
|
|
* |
674
|
|
|
* Verifie si un fichier un sous dossier du repertoire /public/lib existe |
675
|
|
|
* |
676
|
|
|
* @param string $name nom du fichier dont on veut verifier |
677
|
|
|
*/ |
678
|
|
|
function lib_exist(string $name = ''): bool |
679
|
|
|
{ |
680
|
|
|
return file_exists(lib_path($name)); |
681
|
|
|
} |
682
|
|
|
} |
683
|
|
|
|
684
|
|
|
if (! function_exists('less_exist')) { |
685
|
|
|
/** |
686
|
|
|
* LESS EXIST |
687
|
|
|
* |
688
|
|
|
* Verifie si un fichier less ou un sous dossier du repertoire /public/less existe |
689
|
|
|
* |
690
|
|
|
* @param string $name nom du fichier dont on veut verifier |
691
|
|
|
*/ |
692
|
|
|
function less_exist(string $name = ''): bool |
693
|
|
|
{ |
694
|
|
|
return file_exists(less_path($name)); |
695
|
|
|
} |
696
|
|
|
} |
697
|
|
|
|
698
|
|
|
if (! function_exists('img_exist')) { |
699
|
|
|
/** |
700
|
|
|
* IMG EXIST |
701
|
|
|
* |
702
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /public/img existe |
703
|
|
|
* |
704
|
|
|
* @param string $name nom du fichier dont on veut verifier |
705
|
|
|
*/ |
706
|
|
|
function img_exist(string $name = ''): bool |
707
|
|
|
{ |
708
|
|
|
return file_exists(img_path($name)); |
709
|
|
|
} |
710
|
|
|
} |
711
|
|
|
|
712
|
|
|
if (! function_exists('doc_exist')) { |
713
|
|
|
/** |
714
|
|
|
* DOC EXIST |
715
|
|
|
* |
716
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /public/docs existe |
717
|
|
|
* |
718
|
|
|
* @param string $name nom du fichier dont on veut verifier |
719
|
|
|
*/ |
720
|
|
|
function doc_exist(string $name = ''): bool |
721
|
|
|
{ |
722
|
|
|
return file_exists(docs_path($name)); |
723
|
|
|
} |
724
|
|
|
} |
725
|
|
|
|
726
|
|
|
if (! function_exists('video_exist')) { |
727
|
|
|
/** |
728
|
|
|
* VIDEO EXIST |
729
|
|
|
* |
730
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /public/videos existe |
731
|
|
|
* |
732
|
|
|
* @param string $name nom du fichier dont on veut verifier |
733
|
|
|
*/ |
734
|
|
|
function videos_exist(string $name = ''): bool |
735
|
|
|
{ |
736
|
|
|
return file_exists(video_path($name)); |
737
|
|
|
} |
738
|
|
|
} |
739
|
|
|
|
740
|
|
|
if (! function_exists('public_exist')) { |
741
|
|
|
/** |
742
|
|
|
* PUBLIC EXIST |
743
|
|
|
* |
744
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /public existe |
745
|
|
|
* |
746
|
|
|
* @param string $name nom du fichier dont on veut verifier |
747
|
|
|
*/ |
748
|
|
|
function public_exist(string $name = ''): bool |
749
|
|
|
{ |
750
|
|
|
return file_exists(public_path($name)); |
751
|
|
|
} |
752
|
|
|
} |
753
|
|
|
|
754
|
|
|
if (! function_exists('class_exist')) { |
755
|
|
|
/** |
756
|
|
|
* CLASS EXIST |
757
|
|
|
* |
758
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/class existe |
759
|
|
|
* |
760
|
|
|
* @param string $name nom du fichier dont on veut verifier |
761
|
|
|
*/ |
762
|
|
|
function class_exist(string $name = ''): bool |
763
|
|
|
{ |
764
|
|
|
return file_exists(class_path($name)); |
765
|
|
|
} |
766
|
|
|
} |
767
|
|
|
|
768
|
|
|
if (! function_exists('config_exist')) { |
769
|
|
|
/** |
770
|
|
|
* CONFIG EXIST |
771
|
|
|
* |
772
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/config existe |
773
|
|
|
* |
774
|
|
|
* @param string $name nom du fichier dont on veut verifier |
775
|
|
|
*/ |
776
|
|
|
function config_exist(string $name = ''): bool |
777
|
|
|
{ |
778
|
|
|
return file_exists(config_path($name)); |
779
|
|
|
} |
780
|
|
|
} |
781
|
|
|
|
782
|
|
|
if (! function_exists('controller_exist')) { |
783
|
|
|
/** |
784
|
|
|
* CONTROLLER EXIST |
785
|
|
|
* |
786
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/controllers existe |
787
|
|
|
* |
788
|
|
|
* @param string $name nom du fichier dont on veut verifier |
789
|
|
|
* @param bool $only specifie si on veut seulement les contrôleurs (fichiers php ayant le suffixe Controller) |
790
|
|
|
*/ |
791
|
|
|
function controller_exist(string $name = '', bool $only = true): bool |
792
|
|
|
{ |
793
|
|
|
return file_exists(controller_path($name, $only)); |
794
|
|
|
} |
795
|
|
|
} |
796
|
|
|
|
797
|
|
|
if (! function_exists('entity_exist')) { |
798
|
|
|
/** |
799
|
|
|
* ENTITY EXIST |
800
|
|
|
* |
801
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/entities existe |
802
|
|
|
* |
803
|
|
|
* @param string $name nom du fichier dont on veut verifier |
804
|
|
|
* @param bool $only specifie si on veut seulement les fichiers d'entité (fichiers php ayant le suffixe Entity) |
805
|
|
|
*/ |
806
|
|
|
function entity_exist(string $name = '', bool $only = true): bool |
807
|
|
|
{ |
808
|
|
|
return file_exists(entity_path($name, $only)); |
809
|
|
|
} |
810
|
|
|
} |
811
|
|
|
|
812
|
|
|
if (! function_exists('helper_exist')) { |
813
|
|
|
/** |
814
|
|
|
* HELPER EXIST |
815
|
|
|
* |
816
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/helpers ou /system/helpers existe |
817
|
|
|
* |
818
|
|
|
* @param string $name nom du fichier dont on veut verifier |
819
|
|
|
* @param bool $system specifie s'il s'agit des helpers systeme ou applicatif |
820
|
|
|
*/ |
821
|
|
|
function helper_exist(string $name = '', bool $system = false): bool |
822
|
|
|
{ |
823
|
|
|
return file_exists(helper_path($name, $system)); |
824
|
|
|
} |
825
|
|
|
} |
826
|
|
|
|
827
|
|
|
if (! function_exists('library_exist')) { |
828
|
|
|
/** |
829
|
|
|
* LIBRARY EXIST |
830
|
|
|
* |
831
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/libraries ou /system/libraries existe |
832
|
|
|
* |
833
|
|
|
* @param string $name nom du fichier dont on veut verifier |
834
|
|
|
* @param bool $system specifie s'il s'agit des librairies systeme ou applicatif |
835
|
|
|
*/ |
836
|
|
|
function library_exist(string $name = '', bool $system = false): bool |
837
|
|
|
{ |
838
|
|
|
return file_exists(library_path($name, $system)); |
839
|
|
|
} |
840
|
|
|
} |
841
|
|
|
|
842
|
|
|
if (! function_exists('middleware_exist')) { |
843
|
|
|
/** |
844
|
|
|
* MIDDLEWARE EXIST |
845
|
|
|
* |
846
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/middlewares ou /system/middlewares existe |
847
|
|
|
* |
848
|
|
|
* @param string $name nom du fichier dont on veut verifier |
849
|
|
|
* @param bool $system specifie s'il s'agit des middlewares systeme ou applicatif |
850
|
|
|
* @param bool $only specifie si on veut seulement les middlewares (fichiers php ayant le suffixe Middleware) |
851
|
|
|
*/ |
852
|
|
|
function middleware_exist(string $name = '', bool $system = false, bool $only = true): bool |
853
|
|
|
{ |
854
|
|
|
return file_exists(middleware_path($name, $system, $only)); |
855
|
|
|
} |
856
|
|
|
} |
857
|
|
|
|
858
|
|
|
if (! function_exists('model_exist')) { |
859
|
|
|
/** |
860
|
|
|
* MODEL EXIST |
861
|
|
|
* |
862
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/models existe |
863
|
|
|
* |
864
|
|
|
* @param string $name nom du fichier dont on veut verifier |
865
|
|
|
* @param bool $only specifie si on veut seulement les modeles (fichiers php ayant le suffixe Model) |
866
|
|
|
*/ |
867
|
|
|
function model_exist(string $name = '', bool $only = true): bool |
868
|
|
|
{ |
869
|
|
|
return file_exists(model_path($name, $only)); |
870
|
|
|
} |
871
|
|
|
} |
872
|
|
|
|
873
|
|
|
if (! function_exists('resource_exist')) { |
874
|
|
|
/** |
875
|
|
|
* RESOURCE EXIST |
876
|
|
|
* |
877
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/resources/ existe |
878
|
|
|
* |
879
|
|
|
* @param string $name nom du fichier dont on veut verifier |
880
|
|
|
*/ |
881
|
|
|
function resource_exist(string $name = ''): bool |
882
|
|
|
{ |
883
|
|
|
return file_exists(resource_path($name)); |
884
|
|
|
} |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
if (! function_exists('migration_exist')) { |
888
|
|
|
/** |
889
|
|
|
* MIGRATION EXIST |
890
|
|
|
* |
891
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/resources/database/migrations existe |
892
|
|
|
* |
893
|
|
|
* @param string $name nom du fichier dont on veut verifier |
894
|
|
|
*/ |
895
|
|
|
function migration_exist(string $name = ''): bool |
896
|
|
|
{ |
897
|
|
|
return file_exists(migration_path($name)); |
898
|
|
|
} |
899
|
|
|
} |
900
|
|
|
|
901
|
|
|
if (! function_exists('seed_exist')) { |
902
|
|
|
/** |
903
|
|
|
* SEED EXIST |
904
|
|
|
* |
905
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/resources/database/seeds existe |
906
|
|
|
* |
907
|
|
|
* @param string $name nom du fichier dont on veut verifier |
908
|
|
|
*/ |
909
|
|
|
function seed_exist(string $name = ''): bool |
910
|
|
|
{ |
911
|
|
|
return file_exists(seed_path($name)); |
912
|
|
|
} |
913
|
|
|
} |
914
|
|
|
|
915
|
|
|
if (! function_exists('lang_exist')) { |
916
|
|
|
/** |
917
|
|
|
* LANG EXIST |
918
|
|
|
* |
919
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/resources/lang ou /system/constants/lang |
920
|
|
|
* |
921
|
|
|
* @param string $name nom du fichier dont on veut verifier |
922
|
|
|
* @param bool $system specifie s'il s'agit des langues systeme ou applicatif |
923
|
|
|
*/ |
924
|
|
|
function lang_exist(string $name = '', bool $system = false): bool |
925
|
|
|
{ |
926
|
|
|
return file_exists(lang_path($name, $system)); |
927
|
|
|
} |
928
|
|
|
} |
929
|
|
|
|
930
|
|
|
if (! function_exists('service_exist')) { |
931
|
|
|
/** |
932
|
|
|
* SERVICE EXIST |
933
|
|
|
* |
934
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/services existe |
935
|
|
|
* |
936
|
|
|
* @param string $name nom du fichier dont on veut verifier |
937
|
|
|
* @param bool $only specifie si on veut seulement les services (fichier php ayant le suffixe Service) |
938
|
|
|
*/ |
939
|
|
|
function service_exist(string $name = '', bool $only = true): bool |
940
|
|
|
{ |
941
|
|
|
return file_exists(service_path($name, $only)); |
942
|
|
|
} |
943
|
|
|
} |
944
|
|
|
|
945
|
|
|
if (! function_exists('view_exist')) { |
946
|
|
|
/** |
947
|
|
|
* VIEW EXIST |
948
|
|
|
* |
949
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/views existe |
950
|
|
|
* |
951
|
|
|
* @param string $name nom du fichier dont on veut verifier |
952
|
|
|
*/ |
953
|
|
|
function view_exist(string $name = ''): bool |
954
|
|
|
{ |
955
|
|
|
return file_exists(view_path($name)); |
956
|
|
|
} |
957
|
|
|
} |
958
|
|
|
|
959
|
|
|
if (! function_exists('layout_exist')) { |
960
|
|
|
/** |
961
|
|
|
* LAYOUT EXIST |
962
|
|
|
* |
963
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/views/layouts existe |
964
|
|
|
* |
965
|
|
|
* @param string $name nom du fichier dont on veut verifier |
966
|
|
|
*/ |
967
|
|
|
function layout_exist(string $name = ''): bool |
968
|
|
|
{ |
969
|
|
|
return file_exists(layout_path($name)); |
970
|
|
|
} |
971
|
|
|
} |
972
|
|
|
|
973
|
|
|
if (! function_exists('partial_exist')) { |
974
|
|
|
/** |
975
|
|
|
* PARTIAL EXIST |
976
|
|
|
* |
977
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/views/partials existe |
978
|
|
|
* |
979
|
|
|
* @param string $name nom du fichier dont on veut verifier |
980
|
|
|
*/ |
981
|
|
|
function partial_exist(string $name = ''): bool |
982
|
|
|
{ |
983
|
|
|
return file_exists(partial_path($name)); |
984
|
|
|
} |
985
|
|
|
} |
986
|
|
|
|
987
|
|
|
if (! function_exists('app_exist')) { |
988
|
|
|
/** |
989
|
|
|
* APP EXIST |
990
|
|
|
* |
991
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /app/ existe |
992
|
|
|
* |
993
|
|
|
* @param string $name nom du fichier dont on veut verifier |
994
|
|
|
*/ |
995
|
|
|
function app_exist(string $name = ''): bool |
996
|
|
|
{ |
997
|
|
|
return file_exists(app_path($name)); |
998
|
|
|
} |
999
|
|
|
} |
1000
|
|
|
|
1001
|
|
|
if (! function_exists('cache_exist')) { |
1002
|
|
|
/** |
1003
|
|
|
* CACHE EXIST |
1004
|
|
|
* |
1005
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /storage/cache existe |
1006
|
|
|
* |
1007
|
|
|
* @param string $name nom du fichier dont on veut verifier |
1008
|
|
|
*/ |
1009
|
|
|
function cache_exist(string $name = ''): bool |
1010
|
|
|
{ |
1011
|
|
|
return file_exists(cache_path($name)); |
1012
|
|
|
} |
1013
|
|
|
} |
1014
|
|
|
|
1015
|
|
|
if (! function_exists('dump_exist')) { |
1016
|
|
|
/** |
1017
|
|
|
* DUMP EXIST |
1018
|
|
|
* |
1019
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /storage/database/dump existe |
1020
|
|
|
* |
1021
|
|
|
* @param string $name nom du fichier dont on veut verifier |
1022
|
|
|
*/ |
1023
|
|
|
function dump_exist(string $name = ''): bool |
1024
|
|
|
{ |
1025
|
|
|
return file_exists(dump_path($name)); |
1026
|
|
|
} |
1027
|
|
|
} |
1028
|
|
|
|
1029
|
|
|
if (! function_exists('storage_exist')) { |
1030
|
|
|
/** |
1031
|
|
|
* STORAGE EXIST |
1032
|
|
|
* |
1033
|
|
|
* Verifie si un fichier ou un sous dossier du repertoire /storage existe |
1034
|
|
|
* |
1035
|
|
|
* @param string $name nom du fichier dont on veut verifier |
1036
|
|
|
*/ |
1037
|
|
|
function storage_exist(string $name = ''): bool |
1038
|
|
|
{ |
1039
|
|
|
return file_exists(storage_path($name)); |
1040
|
|
|
} |
1041
|
|
|
} |
1042
|
|
|
|
1043
|
|
|
if (! function_exists('include_config')) { |
1044
|
|
|
/** |
1045
|
|
|
* INCLUDE CONFIG |
1046
|
|
|
* |
1047
|
|
|
* inclus un fichier de configuration |
1048
|
|
|
* |
1049
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1050
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1051
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1052
|
|
|
*/ |
1053
|
|
|
function include_config(string $name, array $data = [], bool $required = true): void |
1054
|
|
|
{ |
1055
|
|
|
_include_path(config_path($name), $data, $required); |
1056
|
|
|
} |
1057
|
|
|
} |
1058
|
|
|
|
1059
|
|
|
if (! function_exists('include_controller')) { |
1060
|
|
|
/** |
1061
|
|
|
* INCLUDE CONTROLLER |
1062
|
|
|
* |
1063
|
|
|
* inclus un contrôleur |
1064
|
|
|
* |
1065
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1066
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1067
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1068
|
|
|
* @param bool $only specifie si on veut seulement les contrôleurs (fichier php ayant le suffixe Controller) |
1069
|
|
|
*/ |
1070
|
|
|
function include_controller(string $name, array $data = [], bool $required = true, bool $only = true): void |
1071
|
|
|
{ |
1072
|
|
|
_include_path(controller_path($name, $only), $data, $required); |
1073
|
|
|
} |
1074
|
|
|
} |
1075
|
|
|
|
1076
|
|
|
if (! function_exists('include_class')) { |
1077
|
|
|
/** |
1078
|
|
|
* INCLUDE CLASS |
1079
|
|
|
* |
1080
|
|
|
* inclus une classe applicative |
1081
|
|
|
* |
1082
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1083
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1084
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1085
|
|
|
*/ |
1086
|
|
|
function include_class(string $name, array $data = [], bool $required = true): void |
1087
|
|
|
{ |
1088
|
|
|
_include_path(class_path($name), $data, $required); |
1089
|
|
|
} |
1090
|
|
|
} |
1091
|
|
|
|
1092
|
|
|
if (! function_exists('include_entity')) { |
1093
|
|
|
/** |
1094
|
|
|
* INCLUDE ENTITY |
1095
|
|
|
* |
1096
|
|
|
* inclus une entité |
1097
|
|
|
* |
1098
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1099
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1100
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1101
|
|
|
* @param bool $only specifie si on veut seulement les entités (fichier php ayant le suffixe Entity) |
1102
|
|
|
*/ |
1103
|
|
|
function include_entity(string $name, array $data = [], bool $required = true, bool $only = true): void |
1104
|
|
|
{ |
1105
|
|
|
_include_path(entity_path($name, $only), $data, $required); |
1106
|
|
|
} |
1107
|
|
|
} |
1108
|
|
|
|
1109
|
|
|
if (! function_exists('include_helper')) { |
1110
|
|
|
/** |
1111
|
|
|
* INCLUDE HELPER |
1112
|
|
|
* |
1113
|
|
|
* inclus un helper |
1114
|
|
|
* |
1115
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1116
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1117
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1118
|
|
|
*/ |
1119
|
|
|
function include_helper(string $name, array $data = [], bool $required = true): void |
1120
|
|
|
{ |
1121
|
|
|
_include_path(helper_path($name), $data, $required); |
1122
|
|
|
} |
1123
|
|
|
} |
1124
|
|
|
|
1125
|
|
|
if (! function_exists('include_library')) { |
1126
|
|
|
/** |
1127
|
|
|
* INCLUDE LIBRARY |
1128
|
|
|
* |
1129
|
|
|
* inclus une librarie |
1130
|
|
|
* |
1131
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1132
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1133
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1134
|
|
|
* @param bool $system specifie s'il s'agit des librairies systeme ou applicatif |
1135
|
|
|
*/ |
1136
|
|
|
function include_library(string $name, array $data = [], bool $required = true, bool $system = false): void |
1137
|
|
|
{ |
1138
|
|
|
_include_path(library_path($name, $system), $data, $required); |
1139
|
|
|
} |
1140
|
|
|
} |
1141
|
|
|
|
1142
|
|
|
if (! function_exists('include_middleware')) { |
1143
|
|
|
/** |
1144
|
|
|
* INCLUDE MIDDLEWARE |
1145
|
|
|
* |
1146
|
|
|
* inclus un middleware |
1147
|
|
|
* |
1148
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1149
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1150
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1151
|
|
|
* @param bool $system specifie s'il s'agit des middlewares systeme ou applicatif |
1152
|
|
|
* @param bool $only specifie si on veut seulement les middlewares (fichiers php ayant le suffixe Middleware) |
1153
|
|
|
*/ |
1154
|
|
|
function include_middleware(string $name, array $data = [], bool $required = true, bool $system = false, bool $only = true): void |
1155
|
|
|
{ |
1156
|
|
|
_include_path(middleware_path($name, $system, $only), $data, $required); |
1157
|
|
|
} |
1158
|
|
|
} |
1159
|
|
|
|
1160
|
|
|
if (! function_exists('include_model')) { |
1161
|
|
|
/** |
1162
|
|
|
* INCLUDE MODEL |
1163
|
|
|
* |
1164
|
|
|
* inclus un modeèle |
1165
|
|
|
* |
1166
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1167
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1168
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1169
|
|
|
* @param bool $only specifie si on veut seulement les modèles (fichier php ayant le suffixe Model) |
1170
|
|
|
*/ |
1171
|
|
|
function include_model(string $name, array $data = [], bool $required = true, bool $only = true): void |
1172
|
|
|
{ |
1173
|
|
|
_include_path(model_path($name, $only), $data, $required); |
1174
|
|
|
} |
1175
|
|
|
} |
1176
|
|
|
|
1177
|
|
|
if (! function_exists('include_resource')) { |
1178
|
|
|
/** |
1179
|
|
|
* INCLUDE RESOURCE |
1180
|
|
|
* |
1181
|
|
|
* inclus un fichier resource |
1182
|
|
|
* |
1183
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1184
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1185
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1186
|
|
|
*/ |
1187
|
|
|
function include_resource(string $name, array $data = [], bool $required = true): void |
1188
|
|
|
{ |
1189
|
|
|
_include_path(resource_path($name), $data, $required); |
1190
|
|
|
} |
1191
|
|
|
} |
1192
|
|
|
|
1193
|
|
|
if (! function_exists('include_service')) { |
1194
|
|
|
/** |
1195
|
|
|
* INCLUDE SERVICE |
1196
|
|
|
* |
1197
|
|
|
* inclus un service |
1198
|
|
|
* |
1199
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1200
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1201
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1202
|
|
|
* @param bool $only specifie si on veut seulement les services (fichier php ayant le suffixe Service) |
1203
|
|
|
*/ |
1204
|
|
|
function include_service(string $name, array $data = [], bool $required = true, bool $only = true): void |
1205
|
|
|
{ |
1206
|
|
|
_include_path(service_path($name, $only), $data, $required); |
1207
|
|
|
} |
1208
|
|
|
} |
1209
|
|
|
|
1210
|
|
|
if (! function_exists('include_view')) { |
1211
|
|
|
/** |
1212
|
|
|
* INCLUDE VIEW |
1213
|
|
|
* |
1214
|
|
|
* inclus une vue |
1215
|
|
|
* |
1216
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1217
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1218
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1219
|
|
|
*/ |
1220
|
|
|
function include_view(string $name, array $data = [], bool $required = true): void |
1221
|
|
|
{ |
1222
|
|
|
_include_path(view_path($name), $data, $required); |
1223
|
|
|
} |
1224
|
|
|
} |
1225
|
|
|
|
1226
|
|
|
if (! function_exists('include_layout')) { |
1227
|
|
|
/** |
1228
|
|
|
* INCLUDE LAYOUT |
1229
|
|
|
* |
1230
|
|
|
* inclus un template de vue |
1231
|
|
|
* |
1232
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1233
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1234
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1235
|
|
|
*/ |
1236
|
|
|
function include_layout(string $name, array $data = [], bool $required = true): void |
1237
|
|
|
{ |
1238
|
|
|
_include_path(layout_path($name), $data, $required); |
1239
|
|
|
} |
1240
|
|
|
} |
1241
|
|
|
|
1242
|
|
|
if (! function_exists('include_partial')) { |
1243
|
|
|
/** |
1244
|
|
|
* INCLUDE PARTIAL |
1245
|
|
|
* |
1246
|
|
|
* inclus une partie de vue |
1247
|
|
|
* |
1248
|
|
|
* @param string $name nom du fichier dont on veut inclure |
1249
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1250
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1251
|
|
|
*/ |
1252
|
|
|
function include_partial(string $name, array $data = [], bool $required = true): void |
1253
|
|
|
{ |
1254
|
|
|
_include_path(partial_path($name), $data, $required); |
1255
|
|
|
} |
1256
|
|
|
} |
1257
|
|
|
|
1258
|
|
|
if (! function_exists('_include_path')) { |
1259
|
|
|
/** |
1260
|
|
|
* inclus un fichier |
1261
|
|
|
* |
1262
|
|
|
* @param string $path chemin du fichier dont on veut inclure |
1263
|
|
|
* @param array $data les données à transferer dans le fichier inclus |
1264
|
|
|
* @param bool $required specifie si le fichier est obligatoire ou pas |
1265
|
|
|
*/ |
1266
|
|
|
function _include_path(string $path, array $data = [], bool $required = true): void |
1267
|
|
|
{ |
1268
|
|
|
if (file_exists($path)) { |
1269
|
|
|
extract($data); |
1270
|
|
|
require_once $path; |
1271
|
|
|
} elseif (true === $required) { |
1272
|
|
|
throw new Exception("The file '{$path}' does not exist"); |
1273
|
|
|
} |
1274
|
|
|
} |
1275
|
|
|
} |
1276
|
|
|
|