1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Ubiquity\core |
5
|
|
|
* This class is part of Ubiquity |
6
|
|
|
* @author jc |
7
|
|
|
* @version 1.1.0 |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Ubiquity\core; |
12
|
|
|
|
13
|
|
|
use Ubiquity\assets\AssetsManager; |
14
|
|
|
use Ubiquity\cache\CacheManager; |
15
|
|
|
use Ubiquity\contents\normalizers\NormalizersManager; |
16
|
|
|
use Ubiquity\controllers\Router; |
17
|
|
|
use Ubiquity\controllers\Startup; |
18
|
|
|
use Ubiquity\orm\OrmUtils; |
19
|
|
|
use Ubiquity\translation\TranslatorManager; |
20
|
|
|
use Ubiquity\utils\http\UCookie; |
21
|
|
|
use Ubiquity\utils\http\URequest; |
22
|
|
|
use Ubiquity\utils\http\USession; |
23
|
|
|
|
24
|
|
|
class Framework { |
25
|
|
|
public const VERSION = '2.5.0'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Returns framework version. |
29
|
|
|
* @return string |
30
|
|
|
*/ |
31
|
4 |
|
public static function getVersion(): string { |
32
|
4 |
|
return self::VERSION; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Returns the app.env value in config cache. |
37
|
|
|
* @return string |
38
|
|
|
*/ |
39
|
|
|
public static function getEnv(): string { |
40
|
|
|
return Startup::getConfig()['app.env'] ?? 'dev'; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Returns the active controller class name. |
45
|
|
|
* @return string|null |
46
|
|
|
*/ |
47
|
4 |
|
public static function getController(): ?string { |
48
|
4 |
|
return Startup::getController(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Returns the active action. |
53
|
|
|
* @return string|null |
54
|
|
|
*/ |
55
|
5 |
|
public static function getAction(): ?string { |
56
|
5 |
|
return Startup::getAction(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Gets the active URL. |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
4 |
|
public static function getUrl(): string { |
64
|
4 |
|
return \implode('/', Startup::$urlParts); |
65
|
|
|
} |
66
|
|
|
|
67
|
1 |
|
public static function getRouter(): Router { |
68
|
1 |
|
return new Router(); |
69
|
|
|
} |
70
|
|
|
|
71
|
1 |
|
public static function getORM(): OrmUtils { |
72
|
1 |
|
return new OrmUtils(); |
73
|
|
|
} |
74
|
|
|
|
75
|
1 |
|
public static function getRequest(): URequest { |
76
|
1 |
|
return new URequest(); |
77
|
|
|
} |
78
|
|
|
|
79
|
2 |
|
public static function getSession(): USession { |
80
|
2 |
|
return new USession(); |
81
|
|
|
} |
82
|
|
|
|
83
|
1 |
|
public static function getCookies(): UCookie { |
84
|
1 |
|
return new UCookie(); |
85
|
|
|
} |
86
|
|
|
|
87
|
1 |
|
public static function getTranslator(): TranslatorManager { |
88
|
1 |
|
return new TranslatorManager(); |
89
|
|
|
} |
90
|
|
|
|
91
|
1 |
|
public static function getNormalizer(): NormalizersManager { |
92
|
1 |
|
return new NormalizersManager(); |
93
|
|
|
} |
94
|
|
|
|
95
|
4 |
|
public static function hasAdmin(): bool { |
96
|
4 |
|
return \class_exists("controllers\Admin"); |
97
|
|
|
} |
98
|
|
|
|
99
|
1 |
|
public static function getAssets(): AssetsManager { |
100
|
1 |
|
return new AssetsManager(); |
101
|
|
|
} |
102
|
|
|
|
103
|
3 |
|
public static function getCacheSystem(): string { |
104
|
3 |
|
return \get_class(CacheManager::$cache); |
105
|
|
|
} |
106
|
|
|
|
107
|
3 |
|
public static function getAnnotationsEngine(): string { |
108
|
3 |
|
return \get_class(CacheManager::getAnnotationsEngineInstance()); |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
|