You are here

public function ExchangeRateProviderDecorator::loadMultiple in Currency 8.3

Parameters

array[] $currencyCodes: Keys are the ISO 4217 codes of source currencies, values are arrays that contain ISO 4217 codes of destination currencies. Example: [ 'EUR' => ['NLG', 'DEM', 'XXX'], ]

Return value

array[] Keys are the ISO 4217 codes of source currencies, values are arrays of which the keys are ISO 4217 codes of destination currencies and values are \Drupal\currency\ExchangeRateInterface objects, or NULL for combinations of currencies for which no exchange rate could be found.

Overrides ExchangeRateProviderInterface::loadMultiple

File

src/Plugin/Currency/ExchangeRateProvider/ExchangeRateProviderDecorator.php, line 50

Class

ExchangeRateProviderDecorator
Provides an exchange rate provider decorator.

Namespace

Drupal\currency\Plugin\Currency\ExchangeRateProvider

Code

public function loadMultiple(array $currency_codes) {
  $exchange_rates = [];
  foreach ($this->exchangeRateProvider
    ->loadMultiple($currency_codes) as $source_currency_code => $destinations) {
    foreach ($destinations as $destination_currency_code => $exchange_rate) {
      $exchange_rates[$source_currency_code][$destination_currency_code] = ExchangeRate::createFromExchangeRate($exchange_rate, $this
        ->getPluginId());
    }
  }
  return $exchange_rates;
}