Skip to content

Commit

Permalink
added pushing env vars into params with pushEnvVars
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Oct 17, 2017
1 parent 35823f1 commit 05fff11
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,25 @@ public function buildConfig($name, array $configs, $defines = [])
]);
}
$this->vars[$name] = call_user_func_array([Helper::className(), 'mergeConfig'], $configs);
if ($name === 'params') {
$this->vars[$name] = $this->pushEnvVars($this->vars[$name]);
}
$this->writeConfig($name, (array) $this->vars[$name], $defines);
}

protected function pushEnvVars($vars)
{
$env = $this->vars['dotenv'];
foreach (array_keys($vars) as $key) {
$envKey = strtoupper(strtr($key, '.', '_'));
if (isset($env[$envKey])) {
$vars[$key] = $env[$envKey];
}
}

return $vars;
}

protected function isSpecialConfig($name)
{
return in_array($name, ['dotenv', 'defines', 'params'], true);
Expand Down

0 comments on commit 05fff11

Please sign in to comment.