You are here

public function ConfigImporter::importCurrency in Currency 8.3

Imports a currency.

Parameters

string $currency_code:

Return value

\Drupal\currency\Entity\CurrencyInterface|false The imported currency or FALSE in case of errors.

Overrides ConfigImporterInterface::importCurrency

File

src/ConfigImporter.php, line 136

Class

ConfigImporter
Provides a config importer.

Namespace

Drupal\currency

Code

public function importCurrency($currency_code) {
  if (!$this->currencyStorage
    ->load($currency_code)) {
    $currency = $this
      ->createCurrencyFromRepository($currency_code);
    $currency
      ->save();
    return $currency;
  }
  return FALSE;
}