X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FConstant.php;h=253c743a8ba1f01c087719102ea4fcbef77909d3;hb=4b4b8a02477c56182c8df6def1ba14987033dd65;hp=5d941207e4acd50421e157fab187385fd643370d;hpb=57e842c143bb35fef5ae8058b216733f14e16f20;p=civicrm-core.git diff --git a/CRM/Utils/Constant.php b/CRM/Utils/Constant.php index 5d941207e4..253c743a8b 100644 --- a/CRM/Utils/Constant.php +++ b/CRM/Utils/Constant.php @@ -23,20 +23,23 @@ class CRM_Utils_Constant { /** * Determine the value of a constant, if any. * - * If the specified constant is undefined, return a default value. + * If the specified constant is undefined, check for an environment + * variable, defaulting the passed in default value. * * @param string $name * @param mixed $default * (optional) * @return mixed */ - public static function value($name, $default = NULL) { + public static function value(string $name, $default = NULL) { if (defined($name)) { return constant($name); } - else { - return $default; + if (($value = getenv($name)) !== FALSE) { + define($name, $value); + return $value; } + return $default; } }