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