You are here

public static function CountryController::zoneOptionsCallback in Ubercart 8.4

Helper function to return zone options, grouped by country.

File

uc_country/src/Controller/CountryController.php, line 61

Class

CountryController
Utility functions to enable and disable country configuration entities.

Namespace

Drupal\uc_country\Controller

Code

public static function zoneOptionsCallback() {
  $options = [];

  // Must use \Drupal:: because we're in a static function.
  $countries = \Drupal::entityTypeManager()
    ->getStorage('uc_country')
    ->loadByProperties([
    'status' => TRUE,
  ]);
  foreach ($countries as $country) {
    foreach ($country
      ->getZones() as $id => $zone) {
      $options[$id] = $country
        ->label() . ': ' . $zone;
    }
  }
  uasort($options, 'strnatcasecmp');
  return $options;
}