static function CurrencyExchanger::loadMultiple in Currency 7.2
Implements CurrencyExchangerInterface::loadMultiple().
Overrides CurrencyExchangerInterface::loadMultiple
3 calls to CurrencyExchanger::loadMultiple()
- CurrencyExchangerWebTestCase::assertCurrencyExchangeRates in currency/
tests/ CurrencyConverterWebTestCase.test - Asserts that exchange rates can be retrieved.
- CurrencyExchangerWebTestCase::assertIdenticalCurrencyExchangeRates in currency/
tests/ CurrencyConverterWebTestCase.test - Assert sthat exchange rates for identical currencies can be retrieved.
- currency_exchange_rate_db_table_refresh in currency_exchange_rate_db_table/
currency_exchange_rate_db_table.module - Updates the exchange rates stored in the database table.
File
- currency/
includes/ CurrencyExchanger.inc, line 82 - Contains class CurrencyExchanger.
Class
- CurrencyExchanger
- A currency exchanger that uses other available currency exchangers to load exchange rates.
Code
static function loadMultiple(array $currency_codes) {
$rates = array();
// Set rates for identical source and destination currencies.
foreach ($currency_codes as $currency_code_from => $currency_codes_to) {
foreach ($currency_codes_to as $index => $currency_code_to) {
if ($currency_code_from == $currency_code_to) {
$rates[$currency_code_from][$currency_code_to] = 1;
unset($currency_codes[$currency_code_from][$index]);
}
}
}
foreach (self::loadExchangers() as $exchanger) {
foreach ($exchanger::loadMultiple($currency_codes) as $currency_code_from => $currency_codes_to) {
foreach ($currency_codes_to as $currency_code_to => $rate) {
$rates[$currency_code_from][$currency_code_to] = $rate;
// If we found a rate, prevent it from being looked up by the next exchanger.
if ($rate) {
$index = array_search($currency_code_to, $currency_codes[$currency_code_from]);
unset($currency_codes[$currency_code_from][$index]);
}
}
}
}
return $rates;
}