|
|
@@ -39,6 +39,9 @@ namespace OC; |
|
|
|
* configuration file of ownCloud. |
|
|
|
*/ |
|
|
|
class Config { |
|
|
|
|
|
|
|
const ENV_PREFIX = 'OC_'; |
|
|
|
|
|
|
|
/** @var array Associative array ($key => $value) */ |
|
|
|
protected $cache = array(); |
|
|
|
/** @var string */ |
|
|
@@ -71,15 +74,22 @@ class Config { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Gets a value from config.php |
|
|
|
* Returns a config value |
|
|
|
* |
|
|
|
* If it does not exist, $default will be returned. |
|
|
|
* gets its value from an `OC_` prefixed environment variable |
|
|
|
* if it doesn't exist from config.php |
|
|
|
* if this doesn't exist either, it will return the given `$default` |
|
|
|
* |
|
|
|
* @param string $key key |
|
|
|
* @param mixed $default = null default value |
|
|
|
* @return mixed the value or $default |
|
|
|
*/ |
|
|
|
public function getValue($key, $default = null) { |
|
|
|
$envValue = getenv(self::ENV_PREFIX . $key); |
|
|
|
if ($envValue) { |
|
|
|
return $envValue; |
|
|
|
} |
|
|
|
|
|
|
|
if (isset($this->cache[$key])) { |
|
|
|
return $this->cache[$key]; |
|
|
|
} |