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 1919 */
2020class Reader
2121{
22+ const CONFIG_ENV_MODE = 'CONFIG_ENV_MODE ' ;
23+
2224 /**
2325 * @var DirectoryList
2426 */
@@ -41,6 +43,11 @@ class Reader
4143 */
4244 private $ files ;
4345
46+ /**
47+ * @var string
48+ */
49+ private $ configEnvMode ;
50+
4451 /**
4552 * Constructor
4653 *
@@ -92,6 +99,11 @@ public function getFiles()
9299 */
93100 public function load ($ fileKey = null )
94101 {
102+ $ configEnvMode = $ this ->getConfigEnvMode ();
103+ if ($ configEnvMode ) {
104+ putenv (self ::CONFIG_ENV_MODE . "= " . $ configEnvMode );
105+ }
106+
95107 $ path = $ this ->dirList ->getPath (DirectoryList::CONFIG );
96108 $ fileDriver = $ this ->driverPool ->getDriver (DriverPool::FILE );
97109 $ result = [];
@@ -120,6 +132,27 @@ public function load($fileKey = null)
120132 return $ result ?: [];
121133 }
122134
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+
123156 /**
124157 * Loads the configuration file.
125158 *
Original file line number Diff line number Diff line change 1313class ConfigFilePool
1414{
1515 const APP_CONFIG = 'app_config ' ;
16+ const APP_CONFIG_ENV = 'app_config_env ' ;
1617 const APP_ENV = 'app_env ' ;
1718
1819 /**
@@ -32,6 +33,7 @@ class ConfigFilePool
3233 */
3334 private $ applicationConfigFiles = [
3435 self ::APP_CONFIG => 'config.php ' ,
36+ self ::APP_CONFIG_ENV => 'config_env.php ' ,
3537 self ::APP_ENV => 'env.php ' ,
3638 ];
3739
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ public function testGetPaths()
2727 {
2828 $ expected ['new_key ' ] = 'new_config.php ' ;
2929 $ expected [ConfigFilePool::APP_CONFIG ] = 'config.php ' ;
30+ $ expected [ConfigFilePool::APP_CONFIG_ENV ] = 'config_env.php ' ;
3031 $ expected [ConfigFilePool::APP_ENV ] = 'env.php ' ;
3132
3233 $ this ->assertEquals ($ expected , $ this ->configFilePool ->getPaths ());
You can’t perform that action at this time.
0 commit comments