當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Locale\ResolverInterface類代碼示例

本文整理匯總了PHP中Magento\Framework\Locale\ResolverInterface的典型用法代碼示例。如果您正苦於以下問題:PHP ResolverInterface類的具體用法?PHP ResolverInterface怎麽用?PHP ResolverInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ResolverInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * @param \Magento\Framework\View\Element\Template\Context $context
  * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
  * @param \Magento\Core\Helper\PostData $postDataHelper
  * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
  * @param array $data
  */
 public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Core\Helper\PostData $postDataHelper, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data = array())
 {
     $this->_currencyFactory = $currencyFactory;
     $this->_postDataHelper = $postDataHelper;
     parent::__construct($context, $data);
     $this->_locale = $localeResolver->getLocale();
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:14,代碼來源:Currency.php

示例2: __construct

 /**
  * @param Filter $filter
  * @param TimezoneInterface $localeDate
  * @param ResolverInterface $localeResolver
  * @param string $dateFormat
  * @param array $data
  */
 public function __construct(Filter $filter, TimezoneInterface $localeDate, ResolverInterface $localeResolver, $dateFormat = 'M j, Y H:i:s A', array $data = [])
 {
     $this->filter = $filter;
     $this->localeDate = $localeDate;
     $this->locale = $localeResolver->getLocale();
     $this->dateFormat = $dateFormat;
     $this->data = $data;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:15,代碼來源:MetadataProvider.php

示例3: getLang

 /**
  * Get current language
  *
  * @return string
  */
 public function getLang()
 {
     if (!$this->hasData('lang')) {
         $this->setData('lang', substr($this->_localeResolver->getLocale(), 0, 2));
     }
     return $this->getData('lang');
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:12,代碼來源:Page.php

示例4: aroundAddNameToSelect

 /**
  * @param \Magento\Customer\Model\ResourceModel\Customer\Collection $subject
  * @param \Closure $proceed
  * @return \Magento\Customer\Model\ResourceModel\Customer\Collection
  */
 public function aroundAddNameToSelect(Collection $subject, \Closure $proceed)
 {
     $fields = [];
     $customerAccount = $this->fieldsetConfig->getFieldset('customer_account');
     foreach ($customerAccount as $code => $field) {
         if (isset($field['name'])) {
             $fields[$code] = $code;
         }
     }
     $connection = $subject->getConnection();
     $concatenate = [];
     if (isset($fields['prefix'])) {
         $concatenate[] = $connection->getCheckSql('{{prefix}} IS NOT NULL AND {{prefix}} != \'\'', $connection->getConcatSql(['LTRIM(RTRIM({{prefix}}))', '\' \'']), '\'\'');
     }
     if ($this->localeResolver->getLocale() != 'ja_JP') {
         $concatenate[] = 'LTRIM(RTRIM({{firstname}}))';
     } else {
         $concatenate[] = 'LTRIM(RTRIM({{lastname}}))';
     }
     $concatenate[] = '\' \'';
     if (isset($fields['middlename'])) {
         $concatenate[] = $connection->getCheckSql('{{middlename}} IS NOT NULL AND {{middlename}} != \'\'', $connection->getConcatSql(['LTRIM(RTRIM({{middlename}}))', '\' \'']), '\'\'');
     }
     if ($this->localeResolver->getLocale() != 'ja_JP') {
         $concatenate[] = 'LTRIM(RTRIM({{lastname}}))';
     } else {
         $concatenate[] = 'LTRIM(RTRIM({{firstname}}))';
     }
     if (isset($fields['suffix'])) {
         $concatenate[] = $connection->getCheckSql('{{suffix}} IS NOT NULL AND {{suffix}} != \'\'', $connection->getConcatSql(['\' \'', 'LTRIM(RTRIM({{suffix}}))']), '\'\'');
     }
     $nameExpr = $connection->getConcatSql($concatenate);
     $subject->addExpressionAttributeToSelect('name', $nameExpr, $fields);
     return $subject;
 }
開發者ID:magento-japan,項目名稱:m2-jplocalize,代碼行數:40,代碼來源:ModifyName.php

示例5: getPriceFormat

 /**
  * Functions returns array with price formatting info
  *
  * @return array
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function getPriceFormat()
 {
     $localeData = (new DataBundle())->get($this->_localeResolver->getLocale());
     $format = $localeData['NumberElements']['latn']['patterns']['currencyFormat'] ?: explode(';', $localeData['NumberPatterns'][1])[0];
     $decimalSymbol = $localeData['NumberElements']['latn']['symbols']['decimal'] ?: $localeData['NumberElements'][0];
     $groupSymbol = $localeData['NumberElements']['latn']['symbols']['group'] ?: $localeData['NumberElements'][1];
     $pos = strpos($format, ';');
     if ($pos !== false) {
         $format = substr($format, 0, $pos);
     }
     $format = preg_replace("/[^0\\#\\.,]/", "", $format);
     $totalPrecision = 0;
     $decimalPoint = strpos($format, '.');
     if ($decimalPoint !== false) {
         $totalPrecision = strlen($format) - (strrpos($format, '.') + 1);
     } else {
         $decimalPoint = strlen($format);
     }
     $requiredPrecision = $totalPrecision;
     $t = substr($format, $decimalPoint);
     $pos = strpos($t, '#');
     if ($pos !== false) {
         $requiredPrecision = strlen($t) - $pos - $totalPrecision;
     }
     if (strrpos($format, ',') !== false) {
         $group = $decimalPoint - strrpos($format, ',') - 1;
     } else {
         $group = strrpos($format, '.');
     }
     $integerRequired = strpos($format, '.') - strpos($format, '0');
     $result = ['pattern' => $this->_scopeResolver->getScope()->getCurrentCurrency()->getOutputFormat(), 'precision' => $totalPrecision, 'requiredPrecision' => $requiredPrecision, 'decimalSymbol' => $decimalSymbol, 'groupSymbol' => $groupSymbol, 'groupLength' => $group, 'integerRequired' => $integerRequired];
     return $result;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:39,代碼來源:Format.php

示例6: updateAndGetTranslations

 /**
  * Clears cache and updates translations file
  *
  * @return array
  */
 public function updateAndGetTranslations()
 {
     $this->eventManager->dispatch('adminhtml_cache_flush_system');
     $translations = $this->translateResource->getTranslationArray(null, $this->localeResolver->getLocale());
     $this->fileManager->updateTranslationFileContent(json_encode($translations));
     return $translations;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:12,代碼來源:CacheManager.php

示例7: _toHtml

 /**
  * Render block HTML
  *
  * @return string
  */
 protected function _toHtml()
 {
     $localeData = (new DataBundle())->get($this->_localeResolver->getLocale());
     // get days names
     $daysData = $localeData['calendar']['gregorian']['dayNames'];
     $this->assign('days', ['wide' => $this->encoder->encode(array_values(iterator_to_array($daysData['format']['wide']))), 'abbreviated' => $this->encoder->encode(array_values(iterator_to_array($daysData['format']['abbreviated'])))]);
     // get months names
     $monthsData = $localeData['calendar']['gregorian']['monthNames'];
     $this->assign('months', ['wide' => $this->encoder->encode(array_values(iterator_to_array($monthsData['format']['wide']))), 'abbreviated' => $this->encoder->encode(array_values(iterator_to_array($monthsData['format']['abbreviated'])))]);
     // get "today" and "week" words
     $this->assign('today', $this->encoder->encode($localeData['fields']['day']['relative']['0']));
     $this->assign('week', $this->encoder->encode($localeData['fields']['week']['dn']));
     // get "am" & "pm" words
     $this->assign('am', $this->encoder->encode($localeData['calendar']['gregorian']['AmPmMarkers']['0']));
     $this->assign('pm', $this->encoder->encode($localeData['calendar']['gregorian']['AmPmMarkers']['1']));
     // get first day of week and weekend days
     $this->assign('firstDay', (int) $this->_scopeConfig->getValue('general/locale/firstday', \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
     $this->assign('weekendDays', $this->encoder->encode((string) $this->_scopeConfig->getValue('general/locale/weekend', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)));
     // define default format and tooltip format
     $this->assign('defaultFormat', $this->encoder->encode($this->_localeDate->getDateFormat(\IntlDateFormatter::MEDIUM)));
     $this->assign('toolTipFormat', $this->encoder->encode($this->_localeDate->getDateFormat(\IntlDateFormatter::LONG)));
     // get days and months for en_US locale - calendar will parse exactly in this locale
     $englishMonths = (new DataBundle())->get('en_US')['calendar']['gregorian']['monthNames'];
     $enUS = new \stdClass();
     $enUS->m = new \stdClass();
     $enUS->m->wide = array_values(iterator_to_array($englishMonths['format']['wide']));
     $enUS->m->abbr = array_values(iterator_to_array($englishMonths['format']['abbreviated']));
     $this->assign('enUS', $this->encoder->encode($enUS));
     return parent::_toHtml();
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:35,代碼來源:Calendar.php

示例8: testGetLocale

 public function testGetLocale()
 {
     $expected = 'locale';
     $this->locale->expects($this->once())->method('getLocaleCode')->will($this->returnValue($expected));
     $actual = $this->model->getLocale();
     $this->assertSame($expected, $actual);
 }
開發者ID:buskamuza,項目名稱:magento2-skeleton,代碼行數:7,代碼來源:DesignTest.php

示例9: getCurrentLocale

 /**
  * return current locale code
  */
 public function getCurrentLocale()
 {
     if ($this->_localeResolver->getLocale() == 'ja_JP') {
         return 'ja';
     }
     return 'en';
 }
開發者ID:Magento-Japan,項目名稱:m2-jpzip2address,代碼行數:10,代碼來源:Data.php

示例10: mockGridDateRendererBehaviorWithLocale

 /**
  * @param string $locale
  */
 private function mockGridDateRendererBehaviorWithLocale($locale)
 {
     $this->resolverMock->expects($this->any())->method('getLocale')->willReturn($locale);
     $this->localeDate->expects($this->any())->method('getDateFormat')->willReturnCallback(function ($value) use($locale) {
         return (new \IntlDateFormatter($locale, $value, \IntlDateFormatter::NONE))->getPattern();
     });
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:10,代碼來源:DateTest.php

示例11: setupAggregate

 /**
  * Set up aggregate
  *
  * @return \DateTime
  */
 protected function setupAggregate()
 {
     $this->localeResolverMock->expects($this->once())->method('emulate')->with(0);
     $this->localeResolverMock->expects($this->once())->method('revert');
     $date = (new \DateTime())->sub(new \DateInterval('PT25H'));
     $this->localeDateMock->expects($this->once())->method('date')->will($this->returnValue($date));
     return $date;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:13,代碼來源:AggregateSalesReportBestsellersDataTest.php

示例12: _initSelect

 /**
  * Initialize select object
  *
  * @return $this
  */
 protected function _initSelect()
 {
     parent::_initSelect();
     $locale = $this->_localeResolver->getLocale();
     $this->addBindParam(':region_locale', $locale);
     $this->getSelect()->joinLeft(['rname' => $this->_regionNameTable], 'main_table.region_id = rname.region_id AND rname.locale = :region_locale', ['name']);
     return $this;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:13,代碼來源:Collection.php

示例13: testGetConfig

 /**
  * @dataProvider getConfigDataProvider
  */
 public function testGetConfig($configData, $locale, $expectedResult)
 {
     foreach ($configData as $key => $value) {
         $this->configMock->expects($this->any())->method($key)->willReturn($value);
     }
     $this->localResolverMock->expects($this->any())->method('getLocale')->willReturn($locale);
     $this->assertEquals($expectedResult, $this->model->getConfig());
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:11,代碼來源:PayPalTest.php

示例14: outputFilter

 /**
  * Returns the result of filtering $value
  *
  * @param string $value
  * @return string
  */
 public function outputFilter($value)
 {
     $filterInput = new \Zend_Filter_LocalizedToNormalized(['date_format' => DateTime::DATE_INTERNAL_FORMAT, 'locale' => $this->localeResolver->getLocale()]);
     $filterInternal = new \Zend_Filter_NormalizedToLocalized(['date_format' => $this->_dateFormat, 'locale' => $this->localeResolver->getLocale()]);
     $value = $filterInput->filter($value);
     $value = $filterInternal->filter($value);
     return $value;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:14,代碼來源:Date.php

示例15: execute

 /**
  * Refresh sales order report statistics for last day
  *
  * @return void
  */
 public function execute()
 {
     $this->localeResolver->emulate(0);
     $currentDate = $this->localeDate->date();
     $date = $currentDate->sub(new \DateInterval('PT25H'));
     $this->orderFactory->create()->aggregate($date);
     $this->localeResolver->revert();
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:13,代碼來源:AggregateSalesReportOrderData.php


注:本文中的Magento\Framework\Locale\ResolverInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。