You are here

public function CurrencyHelper::getExchangeRatesProviders in Commerce Currency Resolver 8

Return formatted array of available exchange rates plugins.

Return value

array List of keyed providers ['provider_id' => 'Provider name'].

Overrides CurrencyHelperInterface::getExchangeRatesProviders

File

src/CurrencyHelper.php, line 113

Class

CurrencyHelper
Helper for various parts of the module.

Namespace

Drupal\commerce_currency_resolver

Code

public function getExchangeRatesProviders() {

  /** @var \Drupal\commerce_exchanger\Entity\ExchangeRatesInterface[] $providers */
  $providers = $this->entityTypeManager
    ->getStorage('commerce_exchange_rates')
    ->loadMultiple();
  $exchange_rates = [];
  foreach ($providers as $provider) {
    if ($provider
      ->status()) {
      $exchange_rates[$provider
        ->id()] = $provider
        ->label();
    }
  }
  return $exchange_rates;
}