Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update BaseConfig.php #2082

Merged
merged 1 commit into from
Aug 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 44 additions & 41 deletions system/Config/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
*
Expand Down