/** * Construct the LocaleChoiceList * * @param LocaleInformation $information LocaleInformation Service * @param bool $languagesOnly If only Languages should be displayed * @param bool $strictMode If strict mode */ public function __construct(LocaleInformation $information, $languagesOnly = true, $strictMode = false) { $this->localeChoices = array(); if ($strictMode) { $allowedLocales = $information->getAllowedLocalesFromConfiguration(); } else { $allowedLocales = $information->getAllAllowedLanguages(); } foreach ($allowedLocales as $locale) { if ($languagesOnly && strlen($locale) == 2 || !$languagesOnly) { $this->localeChoices[$locale] = Locale::getDisplayName($locale, $locale); } } $this->preferredChoices = $information->getPreferredLocales(); parent::__construct($this->localeChoices, $this->preferredChoices); }
/** * @param bool $intlExtension * * @dataProvider intlExtensionInstalled */ public function testGetAllAllowedLanguagesStrict($intlExtension) { $metaValidator = $this->getMetaValidator($this->allowedLocales, $intlExtension, true); $information = new LocaleInformation($metaValidator, $this->getGuesserManagerMock()); $foundLanguages = $information->getAllAllowedLanguages(); $this->assertCount(count($this->allowedLocales), $foundLanguages); foreach ($foundLanguages as $locale) { $this->assertContains($locale, $this->allowedLocales); } }