You are here

public function FormHelper::getCurrencyLocaleOptions in Currency 8.3

Returns an options list of all currency locales.

Parameters

\Drupal\currency\Entity\CurrencyLocaleInterface[]|null $currency_locales: An array of currency locales to limit the options by, or NULL to allow all currency locales to be selected.

Return value

array Keys are locales. Values are human-readable currency locale labels.

Overrides FormHelperInterface::getCurrencyLocaleOptions

File

src/FormHelper.php, line 70

Class

FormHelper
Provides form helpers.

Namespace

Drupal\currency

Code

public function getCurrencyLocaleOptions(array $currency_locales = NULL) {
  $options = array();

  /** @var \Drupal\currency\Entity\CurrencyLocaleInterface[] $currency_locales */
  if (is_null($currency_locales)) {
    $currency_locales = $this->currencyLocaleStorage
      ->loadMultiple();
  }
  foreach ($currency_locales as $currency_locale) {

    // Do not show disabled currency locales.
    if ($currency_locale
      ->status()) {
      $options[$currency_locale
        ->id()] = $currency_locale
        ->label();
    }
  }
  natcasesort($options);
  return $options;
}