public function CurrencyImporter::getImportable in Price 8
Same name and namespace in other branches
- 3.x src/CurrencyImporter.php \Drupal\price\CurrencyImporter::getImportable()
- 2.0.x src/CurrencyImporter.php \Drupal\price\CurrencyImporter::getImportable()
- 2.x src/CurrencyImporter.php \Drupal\price\CurrencyImporter::getImportable()
- 3.0.x src/CurrencyImporter.php \Drupal\price\CurrencyImporter::getImportable()
Gets a list of importable currencies.
Return value
array An array in the currencyCode => name format.
Overrides CurrencyImporterInterface::getImportable
File
- src/
CurrencyImporter.php, line 56
Class
- CurrencyImporter
- Default implementation of the currency importer.
Namespace
Drupal\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;
}