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


PHP Locale\FormatInterface类代码示例

本文整理汇总了PHP中Magento\Framework\Locale\FormatInterface的典型用法代码示例。如果您正苦于以下问题:PHP FormatInterface类的具体用法?PHP FormatInterface怎么用?PHP FormatInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setUp

 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->mathDivision = $this->getMock('\\Magento\\Framework\\Math\\Division', ['getExactDivision'], [], '', false);
     $this->localeFormat = $this->getMockForAbstractClass('\\Magento\\Framework\\Locale\\FormatInterface', ['getNumber']);
     $this->localeFormat->expects($this->any())->method('getNumber')->willReturn($this->qty);
     $this->object = $this->objectManagerHelper->getObject('Magento\\Framework\\DataObject');
     $this->objectFactory = $this->getMock('\\Magento\\Framework\\DataObject\\Factory', ['create'], [], '', false);
     $this->objectFactory->expects($this->any())->method('create')->willReturn($this->object);
     $this->product = $this->getMock('Magento\\Catalog\\Model\\Product', ['load', 'isComposite', '__wakeup', 'isSaleable'], [], '', false);
     $this->productFactory = $this->getMock('Magento\\Catalog\\Model\\ProductFactory', ['create'], [], '', false);
     $this->productFactory->expects($this->any())->method('create')->willReturn($this->product);
     $this->stockStateProvider = $this->objectManagerHelper->getObject('Magento\\CatalogInventory\\Model\\StockStateProvider', ['mathDivision' => $this->mathDivision, 'localeFormat' => $this->localeFormat, 'objectFactory' => $this->objectFactory, 'productFactory' => $this->productFactory, 'qtyCheckApplicable' => $this->qtyCheckApplicable]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:StockStateProviderTest.php

示例2: filter

 /**
  * Filter value
  *
  * @param float $value
  * @return string
  */
 public function filter($value)
 {
     $value = $this->_localeFormat->getNumber($value);
     $value = $this->priceCurrency->round($this->_rate * $value);
     $value = sprintf("%f", $value);
     return $this->_currency->toCurrency($value);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Filter.php

示例3: getJsConfig

 /**
  * Js configuration array for autocomplete
  *
  * @return array
  */
 public function getJsConfig()
 {
     $config = ["*" => ['Magento_Ui/js/core/app' => ['components' => ['autocompleteInjection' => ['component' => 'Mirasvit_SearchAutocomplete/js/injection', 'config' => []], 'autocomplete' => ['component' => 'Mirasvit_SearchAutocomplete/js/autocomplete', 'provider' => 'autocompleteProvider', 'config' => ['query' => $this->searchHelper->getEscapedQueryText(), 'priceFormat' => $this->localeFormat->getPriceFormat()]], 'autocompleteProvider' => ['component' => 'Mirasvit_SearchAutocomplete/js/provider', 'config' => ['url' => $this->getUrl('searchautocomplete/ajax/suggest', ['_secure' => $this->getRequest()->isSecure()]), 'delay' => $this->config->getDelay(), 'minSearchLength' => $this->config->getMinChars()]], 'autocompleteNavigation' => ['component' => 'Mirasvit_SearchAutocomplete/js/navigation', 'autocomplete' => 'autocomplete']]]]];
     if ($this->config->isShowPopularSearches()) {
         $config['*']['Magento_Ui/js/core/app']['components']['autocompletePopular'] = ['component' => 'Mirasvit_SearchAutocomplete/js/popular', 'autocomplete' => 'autocomplete', 'provider' => 'autocompleteProvider', 'config' => ['enabled' => $this->config->isShowPopularSearches(), 'queries' => $this->config->getPopularSearches()]];
     } else {
         $config['*']['Magento_Ui/js/core/app']['components']['autocompleteRecent'] = ['component' => 'Mirasvit_SearchAutocomplete/js/recent', 'autocomplete' => 'autocomplete', 'provider' => 'autocompleteProvider', 'config' => ['limit' => 5]];
     }
     return $config;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:Injection.php

示例4: aroundGetData

 /**
  * Append virtual rule and sorting product data.
  *
  * @param CategoryDataProvider $dataProvider Data provider.
  * @param \Closure             $proceed      Original method.
  *
  * @return array
  */
 public function aroundGetData(CategoryDataProvider $dataProvider, \Closure $proceed)
 {
     $data = $proceed();
     $currentCategory = $dataProvider->getCurrentCategory();
     if ($currentCategory->getId() === null || $currentCategory->getLevel() < 2) {
         $data[$currentCategory->getId()]['use_default']['is_virtual_category'] = true;
     }
     $data[$currentCategory->getId()]['sorted_products'] = $this->getProductSavedPositions($currentCategory);
     $data[$currentCategory->getId()]['product_sorter_load_url'] = $this->getProductSorterLoadUrl($currentCategory);
     $data[$currentCategory->getId()]['price_format'] = $this->localeFormat->getPriceFormat();
     return $data;
 }
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:20,代码来源:DataProviderPlugin.php

示例5: filter

 /**
  * Filter value
  *
  * @param float $value
  * @return string
  */
 public function filter($value)
 {
     $value = $this->_localeFormat->getNumber($value);
     $value = $this->_storeManager->getStore()->roundPrice($this->_rate * $value);
     $value = sprintf("%f", $value);
     return $this->_currency->toCurrency($value);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:13,代码来源:Filter.php

示例6: getConfig

 /**
  * {@inheritdoc}
  */
 public function getConfig()
 {
     $quoteId = $this->checkoutSession->getQuote()->getId();
     $output['formKey'] = $this->formKey->getFormKey();
     $output['customerData'] = $this->getCustomerData();
     $output['quoteData'] = $this->getQuoteData();
     $output['quoteItemData'] = $this->getQuoteItemData();
     $output['isCustomerLoggedIn'] = $this->isCustomerLoggedIn();
     $output['selectedShippingMethod'] = $this->getSelectedShippingMethod();
     $output['storeCode'] = $this->getStoreCode();
     $output['isGuestCheckoutAllowed'] = $this->isGuestCheckoutAllowed();
     $output['isCustomerLoginRequired'] = $this->isCustomerLoginRequired();
     $output['registerUrl'] = $this->getRegisterUrl();
     $output['checkoutUrl'] = $this->getCheckoutUrl();
     $output['pageNotFoundUrl'] = $this->pageNotFoundUrl();
     $output['forgotPasswordUrl'] = $this->getForgotPasswordUrl();
     $output['staticBaseUrl'] = $this->getStaticBaseUrl();
     $output['priceFormat'] = $this->localeFormat->getPriceFormat(null, $this->checkoutSession->getQuote()->getQuoteCurrencyCode());
     $output['basePriceFormat'] = $this->localeFormat->getPriceFormat(null, $this->checkoutSession->getQuote()->getBaseCurrencyCode());
     $output['postCodes'] = $this->postCodesConfig->getPostCodes();
     $output['imageData'] = $this->imageProvider->getImages($quoteId);
     $output['defaultCountryId'] = $this->directoryHelper->getDefaultCountry();
     $output['totalsData'] = $this->getTotalsData();
     $output['shippingPolicy'] = ['isEnabled' => $this->scopeConfig->isSetFlag('shipping/shipping_policy/enable_shipping_policy', ScopeInterface::SCOPE_STORE), 'shippingPolicyContent' => nl2br($this->scopeConfig->getValue('shipping/shipping_policy/shipping_policy_content', ScopeInterface::SCOPE_STORE))];
     $output['activeCarriers'] = $this->getActiveCarriers();
     $output['originCountryCode'] = $this->getOriginCountryCode();
     $output['paymentMethods'] = $this->getPaymentMethods();
     $output['autocomplete'] = $this->isAutocompleteEnabled();
     return $output;
 }
开发者ID:nblair,项目名称:magescotch,代码行数:33,代码来源:DefaultConfigProvider.php

示例7: getJsonConfig

 /**
  * Get JSON encoded configuration array which can be used for JS dynamic
  * price calculation depending on product options
  *
  * @return string
  */
 public function getJsonConfig()
 {
     $config = array();
     if (!$this->hasOptions()) {
         return $this->_jsonEncoder->encode($config);
     }
     $customerId = $this->getCustomerId();
     /* @var $product \Magento\Catalog\Model\Product */
     $product = $this->getProduct();
     $defaultTax = $this->taxCalculationService->getDefaultCalculatedRate($product->getTaxClassId(), $customerId);
     $currentTax = $this->taxCalculationService->getCalculatedRate($product->getTaxClassId(), $customerId);
     $tierPrices = array();
     $tierPricesList = $product->getPriceInfo()->getPrice('tier_price')->getTierPriceList();
     foreach ($tierPricesList as $tierPrice) {
         $tierPrices[] = $this->_coreData->currency($tierPrice['price']->getValue(), false, false);
     }
     $config = array('productId' => $product->getId(), 'priceFormat' => $this->_localeFormat->getPriceFormat(), 'includeTax' => $this->_taxData->priceIncludesTax() ? 'true' : 'false', 'showIncludeTax' => $this->_taxData->displayPriceIncludingTax(), 'showBothPrices' => $this->_taxData->displayBothPrices(), 'productPrice' => $this->_coreData->currency($product->getPriceInfo()->getPrice('final_price')->getValue(), false, false), 'productOldPrice' => $this->_coreData->currency($product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue(), false, false), 'inclTaxPrice' => $this->_coreData->currency($product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue(), false, false), 'exclTaxPrice' => $this->_coreData->currency($product->getPriceInfo()->getPrice('final_price')->getAmount()->getBaseAmount(), false, false), 'defaultTax' => $defaultTax, 'currentTax' => $currentTax, 'idSuffix' => '_clone', 'oldPlusDisposition' => 0, 'plusDisposition' => 0, 'plusDispositionTax' => 0, 'oldMinusDisposition' => 0, 'minusDisposition' => 0, 'tierPrices' => $tierPrices);
     $responseObject = new \Magento\Framework\Object();
     $this->_eventManager->dispatch('catalog_product_view_config', array('response_object' => $responseObject));
     if (is_array($responseObject->getAdditionalOptions())) {
         foreach ($responseObject->getAdditionalOptions() as $option => $value) {
             $config[$option] = $value;
         }
     }
     return $this->_jsonEncoder->encode($config);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:32,代码来源:View.php

示例8: getNumber

 /**
  * @param string|float|int|null $qty
  * @return float|null
  */
 protected function getNumber($qty)
 {
     if (!is_numeric($qty)) {
         $qty = $this->localeFormat->getNumber($qty);
         return $qty;
     }
     return $qty;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:StockStateProvider.php

示例9: getConfigData

 /**
  * Get formed config data from calculated options data
  *
  * @param Product $product
  * @param array $options
  * @return array
  */
 private function getConfigData(Product $product, array $options)
 {
     $isFixedPrice = $this->getProduct()->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_FIXED;
     $productAmount = $product->getPriceInfo()->getPrice(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)->getPriceWithoutOption();
     $baseProductAmount = $product->getPriceInfo()->getPrice(\Magento\Catalog\Pricing\Price\RegularPrice::PRICE_CODE)->getAmount();
     $config = ['options' => $options, 'selected' => $this->selectedOptions, 'bundleId' => $product->getId(), 'priceFormat' => $this->localeFormat->getPriceFormat(), 'prices' => ['oldPrice' => ['amount' => $isFixedPrice ? $baseProductAmount->getValue() : 0], 'basePrice' => ['amount' => $isFixedPrice ? $productAmount->getBaseAmount() : 0], 'finalPrice' => ['amount' => $isFixedPrice ? $productAmount->getValue() : 0]], 'priceType' => $product->getPriceType(), 'isFixedPrice' => $isFixedPrice];
     return $config;
 }
开发者ID:Coplex,项目名称:magento2,代码行数:15,代码来源:Bundle.php

示例10: getPriceFormat

 /**
  * Get prices javascript format json
  *
  * @param  null|int|string|Store $store
  * @return string
  */
 public function getPriceFormat($store = null)
 {
     $this->_localeResolver->emulate($store);
     $priceFormat = $this->_localeFormat->getPriceFormat();
     $this->_localeResolver->revert();
     if ($store) {
         $priceFormat['pattern'] = $this->_storeManager->getStore($store)->getCurrentCurrency()->getOutputFormat();
     }
     return $this->jsonHelper->jsonEncode($priceFormat);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:Data.php

示例11: getFieldFormat

 /**
  * Retrieve Field Format for slider display
  *
  * @return array
  */
 protected function getFieldFormat()
 {
     $format = $this->localeFormat->getPriceFormat();
     $attribute = $this->getFilter()->getAttributeModel();
     $format['pattern'] = (string) $attribute->getDisplayPattern();
     $format['precision'] = (int) $attribute->getDisplayPrecision();
     $format['requiredPrecision'] = (int) $attribute->getDisplayPrecision();
     $format['integerRequired'] = (int) $attribute->getDisplayPrecision() > 0;
     return $format;
 }
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:15,代码来源:Slider.php

示例12: prepareValue

 /**
  * @param string $entityType
  * @param string $value
  * @param AbstractAttribute $attribute
  * @return string
  * @throws \Exception
  */
 protected function prepareValue($entityType, $value, AbstractAttribute $attribute)
 {
     $metadata = $this->metadataPool->getMetadata($entityType);
     $type = $attribute->getBackendType();
     if (($type == 'int' || $type == 'decimal' || $type == 'datetime') && $value === '') {
         $value = null;
     } elseif ($type == 'decimal') {
         $value = $this->localeFormat->getNumber($value);
     }
     $describe = $metadata->getEntityConnection()->describeTable($attribute->getBackendTable());
     return $metadata->getEntityConnection()->prepareColumnValue($describe['value'], $value);
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:19,代码来源:AttributePersistor.php

示例13: formatTxt

 /**
  * @param float $price
  * @param array $options
  * @return string
  */
 public function formatTxt($price, $options = [])
 {
     if (!is_numeric($price)) {
         $price = $this->_localeFormat->getNumber($price);
     }
     /**
      * Fix problem with 12 000 000, 1 200 000
      *
      * %f - the argument is treated as a float, and presented as a floating-point number (locale aware).
      * %F - the argument is treated as a float, and presented as a floating-point number (non-locale aware).
      */
     $price = sprintf("%F", $price);
     return $this->_localeCurrency->getCurrency($this->getCode())->toCurrency($price, $options);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:19,代码来源:Currency.php

示例14: getConfig

 /**
  * {@inheritdoc}
  */
 public function getConfig()
 {
     $configuration = [];
     $configuration['giftMessage'] = [];
     $orderLevelGiftMessageConfiguration = (bool) $this->scopeConfiguration->getValue(GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     $itemLevelGiftMessageConfiguration = (bool) $this->scopeConfiguration->getValue(GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     if ($orderLevelGiftMessageConfiguration) {
         $orderMessages = $this->getOrderLevelGiftMessages();
         $configuration['isOrderLevelGiftOptionsEnabled'] = (bool) $this->isQuoteVirtual() ? false : true;
         $configuration['giftMessage']['orderLevel'] = $orderMessages === null ? true : $orderMessages->getData();
     }
     $itemMessages = $this->getItemLevelGiftMessages();
     $configuration['isItemLevelGiftOptionsEnabled'] = $itemLevelGiftMessageConfiguration;
     $configuration['giftMessage']['itemLevel'] = $itemMessages === null ? true : $itemMessages;
     $configuration['priceFormat'] = $this->localeFormat->getPriceFormat(null, $this->checkoutSession->getQuote()->getQuoteCurrencyCode());
     $configuration['storeCode'] = $this->getStoreCode();
     $configuration['isCustomerLoggedIn'] = $this->isCustomerLoggedIn();
     $configuration['formKey'] = $this->formKey->getFormKey();
     $store = $this->storeManager->getStore();
     $configuration['baseUrl'] = $store->isFrontUrlSecure() ? $store->getBaseUrl(UrlInterface::URL_TYPE_LINK, true) : $store->getBaseUrl(UrlInterface::URL_TYPE_LINK, false);
     return $configuration;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:25,代码来源:GiftMessageConfigProvider.php

示例15: loadArray

 /**
  * Load array
  *
  * @param array $arr
  * @return $this
  */
 public function loadArray($arr)
 {
     $this->setAttribute(isset($arr['attribute']) ? $arr['attribute'] : false);
     $attribute = $this->getAttributeObject();
     $isContainsOperator = !empty($arr['operator']) && in_array($arr['operator'], array('{}', '!{}'));
     if ($attribute && $attribute->getBackendType() == 'decimal' && !$isContainsOperator) {
         if (isset($arr['value'])) {
             if (!empty($arr['operator']) && in_array($arr['operator'], array('!()', '()')) && false !== strpos($arr['value'], ',')) {
                 $tmp = array();
                 foreach (explode(',', $arr['value']) as $value) {
                     $tmp[] = $this->_localeFormat->getNumber($value);
                 }
                 $arr['value'] = implode(',', $tmp);
             } else {
                 $arr['value'] = $this->_localeFormat->getNumber($arr['value']);
             }
         } else {
             $arr['value'] = false;
         }
         $arr['is_value_parsed'] = isset($arr['is_value_parsed']) ? $this->_localeFormat->getNumber($arr['is_value_parsed']) : false;
     }
     return parent::loadArray($arr);
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:29,代码来源:AbstractProduct.php


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