You are here

function _telephone_formatter_get_country_codes in Telephone Formatter 7

Get list of all available countries with codes.

Return value

array Returns list of all countries from iso.inc file cross referenced with available country codes.

1 call to _telephone_formatter_get_country_codes()
telephone_formatter_field_formatter_settings_form in ./telephone_formatter.module
Implements hook_field_formatter_settings_form().

File

./telephone_formatter.module, line 179

Code

function _telephone_formatter_get_country_codes() {
  include_once DRUPAL_ROOT . '/includes/iso.inc';
  $phone_util = PhoneNumberUtil::getInstance();
  $regions = array();
  foreach (_country_get_predefined_list() as $region => $name) {
    $region_meta = $phone_util
      ->getMetadataForRegion($region);
    if (is_object($region_meta)) {
      $regions[$region] = $name . ' - +' . $region_meta
        ->getCountryCode() . ' ' . $region_meta
        ->getLeadingDigits();
    }
  }
  return $regions;
}