Example #1
0
 /**
  * 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 = $this->_localeConfig->getAllowedLocales();
     if (!$localeCode || !in_array($localeCode, $allowedLocaleCodes)) {
         $isValid = false;
     }
     return $isValid;
 }
Example #2
0
 /**
  * Retrieve array of allowed currencies
  *
  * @return array
  */
 protected function _getAllowedCurrencies()
 {
     if ($this->_appState->isInstalled()) {
         $allowed = $this->_scopeResolver->getScope()->getAllowedCurrencies();
     } else {
         $allowed = $this->_config->getAllowedCurrencies();
     }
     return $allowed;
 }
Example #3
0
 /**
  * @inheritdoc
  */
 public function getOptionCurrencies()
 {
     $currencies = $this->getTranslationList('currencytoname');
     $options = array();
     $allowed = $this->_config->getAllowedCurrencies();
     foreach ($currencies as $name => $code) {
         if (!in_array($code, $allowed)) {
             continue;
         }
         $options[] = array('label' => $name, 'value' => $code);
     }
     return $this->_sortOptionArray($options);
 }
Example #4
0
 /**
  * @inheritdoc
  */
 public function getOptionCurrencies()
 {
     $currencies = (new CurrencyBundle())->get($this->localeResolver->getLocale())['Currencies'] ?: [];
     $options = [];
     $allowed = $this->_config->getAllowedCurrencies();
     foreach ($currencies as $code => $data) {
         if (!in_array($code, $allowed)) {
             continue;
         }
         $options[] = ['label' => $data[1], 'value' => $code];
     }
     return $this->_sortOptionArray($options);
 }
Example #5
0
 /**
  * @param ConfigInterface $localeConfig
  */
 public function __construct(ConfigInterface $localeConfig)
 {
     $this->allowedLocales = $localeConfig->getAllowedLocales();
 }
Example #6
0
 /**
  * Constructor
  *
  * @param Zend_Locale $zendLocale
  * @param ConfigInterface $localeConfig
  */
 public function __construct(Zend_Locale $zendLocale, ConfigInterface $localeConfig)
 {
     $this->zendLocale = $zendLocale;
     $this->allowedLocales = $localeConfig->getAllowedLocales();
 }