当前位置: 首页>>代码示例>>PHP>>正文


PHP ResolverInterface::getDefaultLocalePath方法代码示例

本文整理汇总了PHP中Magento\Framework\Locale\ResolverInterface::getDefaultLocalePath方法的典型用法代码示例。如果您正苦于以下问题:PHP ResolverInterface::getDefaultLocalePath方法的具体用法?PHP ResolverInterface::getDefaultLocalePath怎么用?PHP ResolverInterface::getDefaultLocalePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Locale\ResolverInterface的用法示例。


在下文中一共展示了ResolverInterface::getDefaultLocalePath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: startEnvironmentEmulation

 /**
  * Start environment emulation of the specified store
  *
  * Function returns information about initial store environment and emulates environment of another store
  *
  * @param integer $storeId
  * @param string $area
  * @param bool $force A true value will ensure that environment is always emulated, regardless of current store
  * @return void
  */
 public function startEnvironmentEmulation($storeId, $area = \Magento\Framework\App\Area::AREA_FRONTEND, $force = false)
 {
     // Only allow a single level of emulation
     if ($this->initialEnvironmentInfo !== null) {
         $this->logger->error(__('Environment emulation nesting is not allowed.'));
         return;
     }
     if ($storeId == $this->_storeManager->getStore()->getStoreId() && !$force) {
         return;
     }
     $this->storeCurrentEnvironmentInfo();
     // emulate inline translations
     $this->inlineTranslation->suspend($this->inlineConfig->isActive($storeId));
     // emulate design
     $storeTheme = $this->_viewDesign->getConfigurationDesignTheme($area, ['store' => $storeId]);
     $this->_viewDesign->setDesignTheme($storeTheme, $area);
     if ($area == \Magento\Framework\App\Area::AREA_FRONTEND) {
         $designChange = $this->_design->loadChange($storeId);
         if ($designChange->getData()) {
             $this->_viewDesign->setDesignTheme($designChange->getDesign(), $area);
         }
     }
     // Current store needs to be changed right before locale change and after design change
     $this->_storeManager->setCurrentStore($storeId);
     // emulate locale
     $newLocaleCode = $this->_scopeConfig->getValue($this->_localeResolver->getDefaultLocalePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
     $this->_localeResolver->setLocale($newLocaleCode);
     $this->_translate->setLocale($newLocaleCode);
     $this->_translate->loadData($area);
     return;
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:41,代码来源:Emulation.php

示例2: _emulateLocale

 /**
  * Apply locale of the specified store
  *
  * @param integer $storeId
  * @param string $area
  * @return string initial locale code
  */
 protected function _emulateLocale($storeId, $area = \Magento\Framework\App\Area::AREA_FRONTEND)
 {
     $initialLocaleCode = $this->_localeResolver->getLocaleCode();
     $newLocaleCode = $this->_scopeConfig->getValue($this->_localeResolver->getDefaultLocalePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
     $this->_localeResolver->setLocaleCode($newLocaleCode);
     $this->_translate->setLocale($newLocaleCode)->loadData($area, true);
     return $initialLocaleCode;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:15,代码来源:Emulation.php

示例3: getStoreDate

 /**
  * Retrieve Date value for store
  *
  * @param int $storeId
  * @param string $date
  * @return string|null
  */
 protected function getStoreDate($storeId, $date = null)
 {
     if (!isset($this->dates[$storeId])) {
         $timezone = $this->scopeConfig->getValue($this->localeDate->getDefaultTimezonePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
         $locale = $this->scopeConfig->getValue($this->localeResolver->getDefaultLocalePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
         $locale = new \Zend_Locale($locale);
         $dateObj = new \Magento\Framework\Stdlib\DateTime\Date(null, null, $locale);
         $dateObj->setTimezone($timezone);
         $this->dates[$storeId] = [$dateObj, $locale->getTranslation(null, 'date', $locale)];
     }
     if (!$this->dateTime->isEmptyDate($date)) {
         list($dateObj, $format) = $this->dates[$storeId];
         $dateObj->setDate($date, \Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT);
         return $dateObj->toString($format);
     }
     return null;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:24,代码来源:Full.php

示例4: installDb

 /**
  * Database installation
  *
  * @return $this
  */
 public function installDb()
 {
     $this->_dbUpdater->updateScheme();
     $data = $this->getDataModel()->getConfigData();
     /**
      * Saving host information into DB
      */
     if (!empty($data['use_rewrites'])) {
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_USE_REWRITES, 1);
     }
     if (!empty($data['enable_charts'])) {
         $this->_installSetup->setConfigData(\Magento\Backend\Block\Dashboard::XML_PATH_ENABLE_CHARTS, 1);
     } else {
         $this->_installSetup->setConfigData(\Magento\Backend\Block\Dashboard::XML_PATH_ENABLE_CHARTS, 0);
     }
     if (!empty($data['admin_no_form_key'])) {
         $this->_installSetup->setConfigData('admin/security/use_form_key', 0);
     }
     $unsecureBaseUrl = $this->_storeManager->getStore()->getBaseUrl('web');
     if (!empty($data['unsecure_base_url'])) {
         $unsecureBaseUrl = $data['unsecure_base_url'];
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, $unsecureBaseUrl);
     }
     if (!empty($data['use_secure'])) {
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_IN_FRONTEND, 1);
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $data['secure_base_url']);
         if (!empty($data['use_secure_admin'])) {
             $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_IN_ADMINHTML, 1);
         }
     } elseif (!empty($data['unsecure_base_url'])) {
         $this->_installSetup->setConfigData(\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, $unsecureBaseUrl);
     }
     /**
      * Saving locale information into DB
      */
     $locale = $this->getDataModel()->getLocaleData();
     if (!empty($locale['locale'])) {
         $this->_installSetup->setConfigData($this->_localeResolver->getDefaultLocalePath(), $locale['locale']);
     }
     if (!empty($locale['timezone'])) {
         $this->_installSetup->setConfigData($this->_localeDate->getDefaultTimezonePath(), $locale['timezone']);
     }
     if (!empty($locale['currency'])) {
         $this->_installSetup->setConfigData(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, $locale['currency']);
         $this->_installSetup->setConfigData(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_DEFAULT, $locale['currency']);
         $this->_installSetup->setConfigData(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_ALLOW, $locale['currency']);
     }
     if (!empty($data['order_increment_prefix'])) {
         $this->_setOrderIncrementPrefix($this->_installSetup, $data['order_increment_prefix']);
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:57,代码来源:Installer.php


注:本文中的Magento\Framework\Locale\ResolverInterface::getDefaultLocalePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。