public function CurrencyImporter::getImportable in Commerce Core 8.2
Gets a list of importable currencies.
Return value
array An array in the currencyCode => name format.
Overrides CurrencyImporterInterface::getImportable
File
- modules/
price/ src/ CurrencyImporter.php, line 57
Class
- CurrencyImporter
- Default implementation of the currency importer.
Namespace
Drupal\commerce_priceCode
public function getImportable() {
$imported_currencies = $this->storage
->loadMultiple();
// The getCurrentLanguage() fallback is a workaround for core bug #2684873.
$language = $this->languageManager
->getConfigOverrideLanguage() ?: $this->languageManager
->getCurrentLanguage();
$langcode = $language
->getId();
$all_currencies = $this->externalRepository
->getAll($langcode, 'en');
$importable_currencies = array_diff_key($all_currencies, $imported_currencies);
$importable_currencies = array_map(function ($currency) {
return $currency
->getName();
}, $importable_currencies);
return $importable_currencies;
}