@@ -33,6 +33,13 @@ final class Application
33
33
*/
34
34
protected $ config = [];
35
35
36
+ /**
37
+ * All application config
38
+ *
39
+ * @var array
40
+ */
41
+ protected $ allConfig = [];
42
+
36
43
/**
37
44
* Application instance
38
45
*
@@ -63,10 +70,16 @@ final class Application
63
70
*/
64
71
public function __construct ()
65
72
{
66
- // $this->config = Configuration::get('app');
67
73
self ::$ instance = $ this ;
68
74
$ this ->request = new Request ();
69
75
$ this ->response = new Response ();
76
+ $ this ->loadDotEnv ();
77
+ $ this ->allConfig = Configuration::all ();
78
+ $ this ->loadAppConfig ();
79
+ $ this ->loadHelpers ();
80
+ $ this ->setDefaultTimezone ();
81
+ $ this ->registerErrorHandler ();
82
+ $ this ->registerShutdownHandler ();
70
83
}
71
84
72
85
/**
@@ -94,12 +107,6 @@ protected function setDefaultTimezone()
94
107
*/
95
108
public function run ()
96
109
{
97
- $ this ->loadHelpers ();
98
- $ this ->loadDotEnv ();
99
- $ this ->loadAppConfig ();
100
- $ this ->setDefaultTimezone ();
101
- $ this ->registerErrorHandler ();
102
- $ this ->registerShutdownHandler ();
103
110
$ this ->registerRoutes ();
104
111
$ this ->registerApiRoutes ();
105
112
$ this ->registerMiddlewares ();
@@ -113,7 +120,7 @@ public function run()
113
120
*/
114
121
protected function loadAppConfig ()
115
122
{
116
- $ this ->config = Configuration:: get ( 'app ' ) ;
123
+ $ this ->config = $ this -> allConfig [ 'app ' ] ;
117
124
}
118
125
119
126
/**
@@ -236,7 +243,7 @@ public function shutdownHandler()
236
243
/**
237
244
* Load helper functions
238
245
*/
239
- public static function loadHelpers ()
246
+ public function loadHelpers ()
240
247
{
241
248
require_once (ROOT . DS . 'framework ' . DS . 'Helpers.php ' );
242
249
}
@@ -254,12 +261,6 @@ public function loadDotEnv()
254
261
*/
255
262
public function runConsoleCommand ($ argv )
256
263
{
257
- $ this ->loadHelpers ();
258
- $ this ->loadDotEnv ();
259
- $ this ->loadAppConfig ();
260
- $ this ->setDefaultTimezone ();
261
- $ this ->registerErrorHandler ();
262
- $ this ->registerShutdownHandler ();
263
264
Command::run ($ argv );
264
265
}
265
266
}
0 commit comments