/**
  * {@inheritdoc}
  */
 public function getList($locale = null)
 {
     if ($this->countryRepository) {
         $countryNames = $this->countryRepository->getList($locale);
     } else {
         $locale = $this->canonicalizeLocale($locale);
         $countryNames = $this->regionBundle->getCountryNames($locale);
     }
     return $countryNames;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function getList($locale = null)
 {
     if ($this->countryRepository) {
         $countryNames = $this->countryRepository->getList($locale);
     } else {
         $locale = LocaleHelper::canonicalize($locale);
         // symfony/intl uses underscores.
         $locale = str_replace('-', '_', $locale);
         $countryNames = $this->regionBundle->getCountryNames($locale);
     }
     return $countryNames;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function getCountryNames($locale = null)
 {
     if (null === $locale) {
         $locale = \Locale::getDefault();
     }
     $countries = parent::getCountryNames($locale);
     // "ZZ" is the code for unknown country
     unset($countries['ZZ']);
     // Global countries (f.i. "America") have numeric codes
     // Countries have alphabetic codes
     foreach ($countries as $code => $name) {
         // is_int() does not work, since some numbers start with '0' and
         // thus are stored as strings.
         // The (string) cast is necessary since ctype_digit() returns false
         // for integers.
         if (ctype_digit((string) $code)) {
             unset($countries[$code]);
         }
     }
     $collator = new \Collator($locale);
     $collator->asort($countries);
     return $countries;
 }
Пример #4
0
 public function __construct(StructuredBundleReaderInterface $reader)
 {
     parent::__construct(realpath(IcuData::getResourceDirectory() . '/region'), $reader);
 }
 public function testGetCountryNames()
 {
     $sortedCountries = array('AT' => 'Austria', 'DE' => 'Germany');
     $this->reader->expects($this->once())->method('readEntry')->with(self::RES_DIR, 'en', array('Countries'))->will($this->returnValue($sortedCountries));
     $this->assertSame($sortedCountries, $this->bundle->getCountryNames('en'));
 }