Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/env/PhabricatorEnv.php
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | private static function initializeCommonEnvironment($config_optional) { | ||||
// Write this back into $_ENV, too, so ExecFuture picks it up when creating | // Write this back into $_ENV, too, so ExecFuture picks it up when creating | ||||
// subprocess environments. | // subprocess environments. | ||||
$_ENV['PATH'] = $env_path; | $_ENV['PATH'] = $env_path; | ||||
// If an instance identifier is defined, write it into the environment so | // If an instance identifier is defined, write it into the environment so | ||||
// it's available to subprocesses. | // it's available to subprocesses. | ||||
$instance = self::getEnvConfig('cluster.instance'); | $instance = self::getEnvConfigStr('cluster.instance'); | ||||
if (strlen($instance)) { | if ($instance !== '') { | ||||
putenv('PHABRICATOR_INSTANCE='.$instance); | putenv('PHABRICATOR_INSTANCE='.$instance); | ||||
$_ENV['PHABRICATOR_INSTANCE'] = $instance; | $_ENV['PHABRICATOR_INSTANCE'] = $instance; | ||||
} | } | ||||
PhabricatorEventEngine::initialize(); | PhabricatorEventEngine::initialize(); | ||||
// TODO: Add a "locale.default" config option once we have some reasonable | // TODO: Add a "locale.default" config option once we have some reasonable | ||||
// defaults which aren't silly nonsense. | // defaults which aren't silly nonsense. | ||||
▲ Show 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | public static function getSelectedEnvironmentName() { | ||||
return $env; | return $env; | ||||
} | } | ||||
/* -( Reading Configuration )---------------------------------------------- */ | /* -( Reading Configuration )---------------------------------------------- */ | ||||
/** | /** | ||||
* Get the current configuration setting for a given key. | * Get the current configuration setting for a given key of a generic value. | ||||
* | * | ||||
* If the key is not found, then throw an Exception. | * If the key is not found, then throw an Exception. | ||||
* | * | ||||
* @param string $key Configuration codename. Example: 'phabricator.base-uri' | |||||
* @task read | * @task read | ||||
* @return mixed | |||||
*/ | */ | ||||
public static function getEnvConfig($key) { | public static function getEnvConfig($key) { | ||||
if (!self::$sourceStack) { | if (!self::$sourceStack) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Trying to read configuration "%s" before configuration has been '. | 'Trying to read configuration "%s" before configuration has been '. | ||||
'initialized.', | 'initialized.', | ||||
$key)); | $key)); | ||||
Show All 14 Lines | public static function getEnvConfig($key) { | ||||
} else { | } else { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
"No config value specified for key '%s'.", | "No config value specified for key '%s'.", | ||||
$key)); | $key)); | ||||
} | } | ||||
} | } | ||||
/** | |||||
* Get the current configuration setting for a given key with a string value. | |||||
* | |||||
* If the key is not found, then throw an Exception. | |||||
* | |||||
* @param string $key Configuration codename. Example: 'phabricator.base-uri' | |||||
ollehar: Shouldn't type come before variable name?
https://docs.phpdoc.org/3. | |||||
Done Inline ActionsNice thanks, my fault valerio.bozzolan: Nice thanks, my fault | |||||
* @task read | |||||
* @return string | |||||
*/ | |||||
public static function getEnvConfigStr($key) { | |||||
return (string)self::getEnvConfig($key); | |||||
} | |||||
/** | /** | ||||
* Get the current configuration setting for a given key. If the key | * Get the current configuration setting for a given key. If the key | ||||
* does not exist, return a default value instead of throwing. This is | * does not exist, return a default value instead of throwing. This is | ||||
* primarily useful for migrations involving keys which are slated for | * primarily useful for migrations involving keys which are slated for | ||||
* removal. | * removal. | ||||
* | * | ||||
* @task read | * @task read | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 601 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
Shouldn't type come before variable name?
https://docs.phpdoc.org/3.0/guide/references/phpdoc/tags/param.html
Maybe Phorge is using another convention?