You are here

public function CountryManager::getEnabledList in Ubercart 8.4

Returns a list of country code => country name pairs for enabled countries.

Return value

array An array of country code => country name pairs.

Overrides CountryManagerInterface::getEnabledList

File

uc_country/src/CountryManager.php, line 86

Class

CountryManager
Provides list of countries.

Namespace

Drupal\uc_country

Code

public function getEnabledList() {
  $countries = $this->entityTypeManager
    ->getStorage('uc_country')
    ->loadByProperties([
    'status' => TRUE,
  ]);
  $country_names = [];
  foreach ($countries as $alpha_2 => $country) {

    // We can use non-literals in t() here because the country names are
    // defined in configuration files, so they have been translated.
    $country_names[$alpha_2] = $this
      ->t($country
      ->getName());
  }
  natcasesort($country_names);
  $this->moduleHandler
    ->alter('countries', $country_names);
  return $country_names;
}