You are here

public function ExchangerProviderRemoteBase::import in Commerce Exchanger 8

File

src/Plugin/Commerce/ExchangerProvider/ExchangerProviderRemoteBase.php, line 256

Class

ExchangerProviderRemoteBase
Base class for Commerce exchanger provider plugins.

Namespace

Drupal\commerce_exchanger\Plugin\Commerce\ExchangerProvider

Code

public function import() {
  $exchange_rates = $this
    ->buildExchangeRates();

  // Write new data.
  if (!empty($exchange_rates)) {
    $file = $this->configFactory
      ->getEditable($this
      ->getConfigName());
    $file
      ->setData([
      'rates' => $exchange_rates,
    ]);
    $file
      ->save();
  }
}