本文整理汇总了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);
}
示例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]
);
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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)];
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}