File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
lib/internal/Magento/Framework Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 19
19
*/
20
20
class Reader
21
21
{
22
+ const CONFIG_ENV_MODE = 'CONFIG_ENV_MODE ' ;
23
+
22
24
/**
23
25
* @var DirectoryList
24
26
*/
@@ -41,6 +43,11 @@ class Reader
41
43
*/
42
44
private $ files ;
43
45
46
+ /**
47
+ * @var string
48
+ */
49
+ private $ configEnvMode ;
50
+
44
51
/**
45
52
* Constructor
46
53
*
@@ -92,6 +99,11 @@ public function getFiles()
92
99
*/
93
100
public function load ($ fileKey = null )
94
101
{
102
+ $ configEnvMode = $ this ->getConfigEnvMode ();
103
+ if ($ configEnvMode ) {
104
+ putenv (self ::CONFIG_ENV_MODE . "= " . $ configEnvMode );
105
+ }
106
+
95
107
$ path = $ this ->dirList ->getPath (DirectoryList::CONFIG );
96
108
$ fileDriver = $ this ->driverPool ->getDriver (DriverPool::FILE );
97
109
$ result = [];
@@ -120,6 +132,27 @@ public function load($fileKey = null)
120
132
return $ result ?: [];
121
133
}
122
134
135
+ /**
136
+ * Get CONFIG_ENV_MODE from env.php file configuration
137
+ *
138
+ * @return string
139
+ */
140
+ private function getConfigEnvMode () : string
141
+ {
142
+ if (!isset ($ this ->configEnvMode )) {
143
+ $ configPath = $ this ->dirList ->getPath (DirectoryList::CONFIG );
144
+ $ fileDriver = $ this ->driverPool ->getDriver (DriverPool::FILE );
145
+ $ envFile = $ configPath . '/ ' . $ this ->configFilePool ->getPath (ConfigFilePool::APP_ENV );
146
+ if ($ fileDriver ->isExists ($ envFile )) {
147
+ $ config = include $ envFile ;
148
+ $ this ->configEnvMode = $ config [self ::CONFIG_ENV_MODE ] ?? "" ;
149
+ } else {
150
+ $ this ->configEnvMode = "" ;
151
+ }
152
+ }
153
+ return $ this ->configEnvMode ;
154
+ }
155
+
123
156
/**
124
157
* Loads the configuration file.
125
158
*
Original file line number Diff line number Diff line change 13
13
class ConfigFilePool
14
14
{
15
15
const APP_CONFIG = 'app_config ' ;
16
+ const APP_CONFIG_ENV = 'app_config_env ' ;
16
17
const APP_ENV = 'app_env ' ;
17
18
18
19
/**
@@ -32,6 +33,7 @@ class ConfigFilePool
32
33
*/
33
34
private $ applicationConfigFiles = [
34
35
self ::APP_CONFIG => 'config.php ' ,
36
+ self ::APP_CONFIG_ENV => 'config_env.php ' ,
35
37
self ::APP_ENV => 'env.php ' ,
36
38
];
37
39
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ public function testGetPaths()
27
27
{
28
28
$ expected ['new_key ' ] = 'new_config.php ' ;
29
29
$ expected [ConfigFilePool::APP_CONFIG ] = 'config.php ' ;
30
+ $ expected [ConfigFilePool::APP_CONFIG_ENV ] = 'config_env.php ' ;
30
31
$ expected [ConfigFilePool::APP_ENV ] = 'env.php ' ;
31
32
32
33
$ this ->assertEquals ($ expected , $ this ->configFilePool ->getPaths ());
You can’t perform that action at this time.
0 commit comments