Skip to content

Commit

Permalink
Merge pull request #2082 from zl59503020/patch-3
Browse files Browse the repository at this point in the history
Update BaseConfig.php
lonnieezell authored Aug 20, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 08ec189 + 3ee035d commit d81330a
Showing 1 changed file with 44 additions and 41 deletions.
85 changes: 44 additions & 41 deletions system/Config/BaseConfig.php
Original file line number Diff line number Diff line change
@@ -90,47 +90,7 @@ public function __construct()

foreach ($properties as $property)
{
if (is_array($this->$property))
{
foreach ($this->$property as $key => $val)
{
if ($value = $this->getEnvValue("{$property}.{$key}", $prefix, $shortPrefix))
{
if (! is_null($value))
{
if ($value === 'false')
{
$value = false;
}
elseif ($value === 'true')
{
$value = true;
}

$this->$property[$key] = $value;
}
}
}
}
else
{
if (($value = $this->getEnvValue($property, $prefix, $shortPrefix)) !== false)
{
if (! is_null($value))
{
if ($value === 'false')
{
$value = false;
}
elseif ($value === 'true')
{
$value = true;
}

$this->$property = is_bool($value) ? $value : trim($value, '\'"');
}
}
}
$this->initEnvValue($this->$property, $property, $prefix, $shortPrefix);
}

if (defined('ENVIRONMENT') && ENVIRONMENT !== 'testing')
@@ -144,6 +104,49 @@ public function __construct()

//--------------------------------------------------------------------

/**
* Initialization an environment-specific configuration setting
*
* @param mixed &$property
* @param string $name
* @param string $prefix
* @param string $shortPrefix
*
* @return mixed
*/
protected function initEnvValue(&$property, string $name, string $prefix, string $shortPrefix)
{
if (is_array($property))
{
foreach ($property as $key => $val)
{
$this->initEnvValue($property[$key], "{$name}.{$key}", $prefix, $shortPrefix);
}
}
else
{
if (($value = $this->getEnvValue($name, $prefix, $shortPrefix)) !== false)
{
if (! is_null($value))
{
if ($value === 'false')
{
$value = false;
}
elseif ($value === 'true')
{
$value = true;
}

$property = is_bool($value) ? $value : trim($value, '\'"');
}
}
}
return $property;
}

//--------------------------------------------------------------------

/**
* Retrieve an environment-specific configuration setting
*

0 comments on commit d81330a

Please sign in to comment.