本文整理汇总了PHP中Magento\Framework\Stdlib\DateTime\TimezoneInterface类的典型用法代码示例。如果您正苦于以下问题:PHP TimezoneInterface类的具体用法?PHP TimezoneInterface怎么用?PHP TimezoneInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimezoneInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: getValue
/**
* Retrieve attribute value
*
* @param \Magento\Framework\Object $object
* @return mixed
*/
public function getValue(\Magento\Framework\Object $object)
{
$data = '';
$value = parent::getValue($object);
$format = $this->_localeDate->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM);
if ($value) {
try {
$data = $this->_localeDate->date($value, \Zend_Date::ISO_8601, null, false)->toString($format);
} catch (\Exception $e) {
$data = $this->_localeDate->date($value, null, null, false)->toString($format);
}
}
return $data;
}
开发者ID:aiesh,项目名称:magento2,代码行数:20,代码来源:Datetime.php
示例5: 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
示例6: 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
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例14: 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
示例15: 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
示例16: 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
示例17: beforeLoad
/**
* @param Collection $productCollection
* @param bool $printQuery
* @param bool $logQuery
* @return array
*/
public function beforeLoad(Collection $productCollection, $printQuery = false, $logQuery = false)
{
if (!$productCollection->hasFlag('catalog_rule_loaded')) {
$connection = $this->resource->getConnection();
$store = $this->storeManager->getStore();
$productCollection->getSelect()->joinLeft(['catalog_rule' => $this->resource->getTableName('catalogrule_product_price')], implode(' AND ', ['catalog_rule.product_id = e.entity_id', $connection->quoteInto('catalog_rule.website_id = ?', $store->getWebsiteId()), $connection->quoteInto('catalog_rule.customer_group_id = ?', $this->customerSession->getCustomerGroupId()), $connection->quoteInto('catalog_rule.rule_date = ?', $this->dateTime->formatDate($this->localeDate->scopeDate($store->getId()), false))]), [CatalogRulePrice::PRICE_CODE => 'rule_price']);
$productCollection->setFlag('catalog_rule_loaded', true);
}
return [$printQuery, $logQuery];
}
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:AddCatalogRulePrice.php
示例18: setupAggregate
/**
* Set up aggregate
*
* @return \Magento\Framework\Stdlib\DateTime\DateInterface
*/
protected function setupAggregate()
{
$date = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\Date', ['emulate', 'revert'], [], '', false);
$this->localeResolverMock->expects($this->once())->method('emulate')->with(0);
$this->localeResolverMock->expects($this->once())->method('revert');
$dateMock = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime\\DateInterface')->disableOriginalConstructor()->getMock();
$dateMock->expects($this->once())->method('subHour')->with(25)->will($this->returnValue($date));
$this->localeDateMock->expects($this->once())->method('date')->will($this->returnValue($dateMock));
return $date;
}
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:15,代码来源:AggregateSalesReportInvoicedDataTest.php
示例19: invoke
/**
* Refresh sales tax report statistics for last day
*
* @return $this
*/
public function invoke()
{
$this->localeResolver->emulate(0);
$currentDate = $this->localeDate->date();
$date = $currentDate->modify('-25 hours');
/** @var $reportTax \Magento\Tax\Model\ResourceModel\Report\Tax */
$reportTax = $this->reportTaxFactory->create();
$reportTax->aggregate($date);
$this->localeResolver->revert();
return $this;
}
开发者ID:IlyaGluschenko,项目名称:protection,代码行数:16,代码来源:AggregateSalesReportTaxData.php
示例20: testGetValue
/**
* @dataProvider getValueDataProvider
*/
public function testGetValue(array $data, $expect)
{
if (isset($data['date_format'])) {
$data['date_format'] = $this->_localeDate->getDateFormat($data['date_format']);
}
if (isset($data['time_format'])) {
$data['time_format'] = $this->_localeDate->getTimeFormat($data['time_format']);
}
/** @var $date \Magento\Framework\Data\Form\Element\Date*/
$date = $this->_elementFactory->create('Magento\\Framework\\Data\\Form\\Element\\Date', $data);
$this->assertEquals($expect, $date->getValue());
}
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:DateTest.php
注:本文中的Magento\Framework\Stdlib\DateTime\TimezoneInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论