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


PHP DateTime\TimezoneInterface類代碼示例

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


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

示例1: setUp

 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->entityFactoryMock = $this->getMockBuilder('Magento\\Framework\\Data\\Collection\\EntityFactory')->disableOriginalConstructor()->getMock();
     $this->timezoneMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface')->getMock();
     $this->factoryMock = $this->getMockBuilder('Magento\\Reports\\Model\\ResourceModel\\Report\\Collection\\Factory')->disableOriginalConstructor()->getMock();
     $this->timezoneMock->expects($this->any())->method('formatDateTime')->will($this->returnCallback([$this, 'formatDateTime']));
     $this->collection = new Collection($this->entityFactoryMock, $this->timezoneMock, $this->factoryMock);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:11,代碼來源:CollectionTest.php

示例2: __construct

 /**
  * @param TimezoneInterface $localeDate
  *
  * @deprecated
  */
 public function __construct(TimezoneInterface $localeDate)
 {
     $this->_localeDate = $localeDate;
     $this->_localToNormalFilter = new \Zend_Filter_LocalizedToNormalized(
         ['date_format' => $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT)]
     );
     $this->_normalToLocalFilter = new \Zend_Filter_NormalizedToLocalized(
         ['date_format' => \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT]
     );
 }
開發者ID:rafaelstz,項目名稱:magento2,代碼行數:15,代碼來源:Date.php

示例3: setUp

 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->localeDate = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface')->disableOriginalConstructor()->getMock();
     $this->localeDate->expects($this->once())->method('date')->willReturnArgument(0);
     $this->contextMock = $this->getMockBuilder('Magento\\Backend\\Block\\Context')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->once())->method('getLocaleDate')->willReturn($this->localeDate);
     $this->resolverMock = $this->getMockBuilder('Magento\\Framework\\Locale\\ResolverInterface')->getMock();
     $this->dateTimeFormatter = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\DateTimeFormatterInterface');
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->date = $objectManager->getObject('Magento\\Reports\\Block\\Adminhtml\\Sales\\Grid\\Column\\Renderer\\Date', ['context' => $this->contextMock, 'localeResolver' => $this->resolverMock, 'dateTimeFormatter' => $this->dateTimeFormatter]);
     $this->globalStateLocaleBackup = \Locale::getDefault();
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:15,代碼來源:DateTest.php

示例4: testToHtml

 public function testToHtml()
 {
     $fieldSet = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Fieldset', [], [], '', false);
     $form = $this->getMock('Magento\\Framework\\Data\\Form', [], [], '', false);
     $attributeModel = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
     $entityType = $this->getMock('Magento\\Eav\\Model\\Entity\\Type', [], [], '', false);
     $formElement = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Text', ['setDisabled'], [], '', false);
     $directoryReadInterface = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface');
     $this->registry->expects($this->any())->method('registry')->with('entity_attribute')->willReturn($attributeModel);
     $this->formFactory->expects($this->any())->method('create')->willReturn($form);
     $form->expects($this->any())->method('addFieldset')->willReturn($fieldSet);
     $form->expects($this->any())->method('getElement')->willReturn($formElement);
     $fieldSet->expects($this->any())->method('addField')->willReturnSelf();
     $attributeModel->expects($this->any())->method('getDefaultValue')->willReturn('default_value');
     $attributeModel->expects($this->any())->method('setDisabled')->willReturnSelf();
     $attributeModel->expects($this->any())->method('getId')->willReturn(1);
     $attributeModel->expects($this->any())->method('getEntityType')->willReturn($entityType);
     $attributeModel->expects($this->any())->method('getIsUserDefined')->willReturn(false);
     $attributeModel->expects($this->any())->method('getAttributeCode')->willReturn('attribute_code');
     $this->localeDate->expects($this->any())->method('getDateFormat')->willReturn('mm/dd/yy');
     $entityType->expects($this->any())->method('getEntityTypeCode')->willReturn('entity_type_code');
     $this->eavData->expects($this->any())->method('getFrontendClasses')->willReturn([]);
     $formElement->expects($this->exactly(3))->method('setDisabled')->willReturnSelf();
     $this->yesNo->expects($this->any())->method('toOptionArray')->willReturn(['yes', 'no']);
     $this->filesystem->expects($this->any())->method('getDirectoryRead')->willReturn($directoryReadInterface);
     $directoryReadInterface->expects($this->any())->method('getRelativePath')->willReturn('relative_path');
     $this->block->setData(['action' => 'save']);
     $this->block->toHtml();
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:29,代碼來源:AdvancedTest.php

示例5: execute

 /**
  * Apply catalog price rules to product in admin
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $product = $observer->getEvent()->getProduct();
     $storeId = $product->getStoreId();
     $date = $this->localeDate->scopeDate($storeId);
     $key = false;
     $ruleData = $this->coreRegistry->registry('rule_data');
     if ($ruleData) {
         $wId = $ruleData->getWebsiteId();
         $gId = $ruleData->getCustomerGroupId();
         $pId = $product->getId();
         $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     } elseif ($product->getWebsiteId() !== null && $product->getCustomerGroupId() !== null) {
         $wId = $product->getWebsiteId();
         $gId = $product->getCustomerGroupId();
         $pId = $product->getId();
         $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     }
     if ($key) {
         if (!$this->rulePricesStorage->hasRulePrice($key)) {
             $rulePrice = $this->resourceRuleFactory->create()->getRulePrice($date, $wId, $gId, $pId);
             $this->rulePricesStorage->setRulePrice($key, $rulePrice);
         }
         if ($this->rulePricesStorage->getRulePrice($key) !== false) {
             $finalPrice = min($product->getData('final_price'), $this->rulePricesStorage->getRulePrice($key));
             $product->setFinalPrice($finalPrice);
         }
     }
     return $this;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:36,代碼來源:ProcessAdminFinalPriceObserver.php

示例6: processCalendarDetails

 public function processCalendarDetails($carrierRate, $carrierGroupDetail)
 {
     $calendarDetails = parent::processCalendarDetails($carrierRate, $carrierGroupDetail);
     //transform for current locale
     $calendarDetails['start'] = $this->localeDate->date($calendarDetails['start'], null, true)->getTimestamp();
     return $calendarDetails;
 }
開發者ID:shipperhq,項目名稱:module-common,代碼行數:7,代碼來源:Calendar.php

示例7: execute

 /**
  * Apply catalog price rules to product on frontend
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $product = $observer->getEvent()->getProduct();
     $pId = $product->getId();
     $storeId = $product->getStoreId();
     if ($observer->hasDate()) {
         $date = new \DateTime($observer->getEvent()->getDate());
     } else {
         $date = $this->localeDate->scopeDate($storeId);
     }
     if ($observer->hasWebsiteId()) {
         $wId = $observer->getEvent()->getWebsiteId();
     } else {
         $wId = $this->storeManager->getStore($storeId)->getWebsiteId();
     }
     if ($observer->hasCustomerGroupId()) {
         $gId = $observer->getEvent()->getCustomerGroupId();
     } elseif ($product->hasCustomerGroupId()) {
         $gId = $product->getCustomerGroupId();
     } else {
         $gId = $this->customerSession->getCustomerGroupId();
     }
     $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     if (!$this->rulePricesStorage->hasRulePrice($key)) {
         $rulePrice = $this->resourceRuleFactory->create()->getRulePrice($date, $wId, $gId, $pId);
         $this->rulePricesStorage->setRulePrice($key, $rulePrice);
     }
     if ($this->rulePricesStorage->getRulePrice($key) !== false) {
         $finalPrice = min($product->getData('final_price'), $this->rulePricesStorage->getRulePrice($key));
         $product->setFinalPrice($finalPrice);
     }
     return $this;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:39,代碼來源:ProcessFrontFinalPriceObserver.php

示例8: execute

 public function execute()
 {
     $startDate = $this->getHelper('M2ePro')->getCurrentGmtDate();
     $synchConfig = $this->modelFactory->getObject('Config\\Manager\\Synchronization');
     $synchConfig->setGroupValue('/ebay/templates/revise/total/', 'start_date', $startDate);
     $synchConfig->setGroupValue('/ebay/templates/revise/total/', 'last_listing_product_id', 0);
     $this->setAjaxContent(json_encode(array('start_date' => $this->localeDate->formatDate($startDate, \IntlDateFormatter::MEDIUM))), false);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:8,代碼來源:runReviseAll.php

示例9: 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

示例10: build

 /**
  * {@inheritdoc}
  */
 public function build($productId)
 {
     $timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
     $currentDate = $this->dateTime->formatDate($timestamp, false);
     $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
     $productTable = $this->resource->getTableName('catalog_product_entity');
     return [$this->resource->getConnection()->select()->from(['parent' => $productTable], '')->joinInner(['link' => $this->resource->getTableName('catalog_product_relation')], "link.parent_id = parent.{$linkField}", [])->joinInner(['child' => $productTable], "child.entity_id = link.child_id", ['entity_id'])->joinInner(['t' => $this->resource->getTableName('catalogrule_product_price')], 't.product_id = child.entity_id', [])->where('parent.entity_id = ? ', $productId)->where('t.website_id = ?', $this->storeManager->getStore()->getWebsiteId())->where('t.customer_group_id = ?', $this->customerSession->getCustomerGroupId())->where('t.rule_date = ?', $currentDate)->order('t.rule_price ' . Select::SQL_ASC)->limit(1)];
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:11,代碼來源:LinkedProductSelectBuilderByCatalogRulePrice.php

示例11: execute

 /**
  * Refresh sales refunded report statistics for last day
  *
  * @return void
  */
 public function execute()
 {
     $this->localeResolver->emulate(0);
     $currentDate = $this->localeDate->date();
     $date = $currentDate->subHour(25);
     $this->refundedFactory->create()->aggregate($date);
     $this->localeResolver->revert();
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:13,代碼來源:AggregateSalesReportRefundedData.php

示例12: 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

示例13: getValue

 /**
  * Returns catalog rule value
  *
  * @return float|boolean
  */
 public function getValue()
 {
     if (null === $this->value) {
         $this->value = $this->resourceRuleFactory->create()->getRulePrice($this->dateTime->scopeTimeStamp($this->storeManager->getStore()->getId()), $this->storeManager->getStore()->getWebsiteId(), $this->customerSession->getCustomerGroupId(), $this->product->getId());
         $this->value = $this->value ? floatval($this->value) : false;
     }
     return $this->value;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:13,代碼來源:CatalogRulePrice.php

示例14: getValue

 /**
  * Retrieve attribute value
  *
  * @param \Magento\Framework\DataObject $object
  * @return mixed
  */
 public function getValue(\Magento\Framework\DataObject $object)
 {
     $data = '';
     $value = parent::getValue($object);
     if ($value) {
         $data = $this->_localeDate->formatDateTime(new \DateTime($value), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE);
     }
     return $data;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:15,代碼來源:Datetime.php

示例15: execute

 /**
  * Refresh sales coupons report statistics for last day
  *
  * @return $this
  */
 public function execute()
 {
     $this->_localeResolver->emulate(0);
     $currentDate = $this->_localeDate->date();
     $date = $currentDate->modify('-25 hours');
     $this->_reportRule->aggregate($date);
     $this->_localeResolver->revert();
     return $this;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:14,代碼來源:AggregateSalesReportCouponsData.php


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