/** * Validate locale code. Code must be in the list of allowed locales. * * @param string $localeCode * @return bool * * @api */ public function isValid($localeCode) { $isValid = true; $allowedLocaleCodes = array_keys($this->lists->getLocaleList()); if (!$localeCode || !in_array($localeCode, $allowedLocaleCodes)) { $isValid = false; } return $isValid; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $table = $this->getHelperSet()->get('table'); $table->setHeaders(['Language', 'Code']); foreach ($this->lists->getLocaleList() as $key => $locale) { $table->addRow([$locale, $key]); } $table->render($output); }
/** * @return ViewModel */ public function indexAction() { $view = new ViewModel([ 'timezone' => $this->list->getTimezoneList(), 'currency' => $this->list->getCurrencyList(), 'language' => $this->list->getLocaleList(), 'isSampledataEnabled' => $this->sampleData->isDeployed(), 'isSampleDataInstalled' => $this->sampleData->isInstalledSuccessfully(), 'isSampleDataErrorInstallation' => $this->sampleData->isInstallationError() ]); $view->setTerminal(true); return $view; }
/** * @return ViewModel */ public function indexAction() { $sampleDataDeployed = $this->moduleList->has('Magento_SampleData'); if ($sampleDataDeployed) { /** @var \Magento\Framework\Setup\SampleData\State $sampleData */ $sampleData = $this->objectManagerProvider->get()->get('Magento\\Framework\\Setup\\SampleData\\State'); $isSampleDataInstalled = $sampleData->isInstalled(); $isSampleDataErrorInstallation = $sampleData->hasError(); } else { $isSampleDataInstalled = false; $isSampleDataErrorInstallation = false; } $view = new ViewModel(['timezone' => $this->list->getTimezoneList(), 'currency' => $this->list->getCurrencyList(), 'language' => $this->list->getLocaleList(), 'isSampleDataInstalled' => $isSampleDataInstalled, 'isSampleDataErrorInstallation' => $isSampleDataErrorInstallation]); $view->setTerminal(true); return $view; }
public function testGetLocaleList() { $locales = array_intersect($this->expectedLocales, array_keys($this->lists->getLocaleList())); $this->assertEquals($this->expectedLocales, $locales); }