static function CurrencyLocalePattern::loadFromEnv in Currency 7.2
Loads a single CurrencyLocalePattern based on environment variables.
If no country code is set in $language->currency_country_code, the "site_default_country" system variable will be used instead. If a CurrencyLocalePattern could not be loaded using these country sources and $language->language, the locale pattern for en_US will be loaded. This is consistent with Drupal's default language, which is US English.
Return value
Throws
RuntimeException
1 call to CurrencyLocalePattern::loadFromEnv()
- CurrencyLocalePatternWebTestCase::testLocaleDelegation in currency/
tests/ CurrencyLocalePatternWebTestCase.test - Tests locale delegation.
File
- currency/
includes/ CurrencyLocalePattern.inc, line 113 - Contains class CurrencyLocalePattern.
Class
- CurrencyLocalePattern
- A currency pattern for a locale.
Code
static function loadFromEnv() {
global $language;
$locale_pattern =& drupal_static('currency_env_locale_pattern');
if (is_null($locale_pattern)) {
// Try this request's country code.
if (self::getCountryCode()) {
$locale_pattern = ctools_export_crud_load('currency_locale_pattern', $language->language . '_' . self::getCountryCode());
}
// Try the global default country code.
if (!$locale_pattern && ($country_code = variable_get('site_default_country', ''))) {
$locale_pattern = ctools_export_crud_load('currency_locale_pattern', $language->language . '_' . $country_code);
}
// Try the Currency default.
if (!$locale_pattern) {
$locale_pattern = ctools_export_crud_load('currency_locale_pattern', CURRENCY_DEFAULT_LOCALE);
}
if (!$locale_pattern) {
throw new RuntimeException(t('The CurrencyLocalePattern en_US could not be loaded.'));
}
}
return $locale_pattern;
}