123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Shipping\Block\Tracking;
- use Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface;
- /**
- * @api
- * @since 100.0.2
- */
- class Popup extends \Magento\Framework\View\Element\Template
- {
- /**
- * Core registry
- *
- * @var \Magento\Framework\Registry
- */
- protected $_registry;
- /**
- * @var DateTimeFormatterInterface
- */
- protected $dateTimeFormatter;
- /**
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param DateTimeFormatterInterface $dateTimeFormatter
- * @param array $data
- */
- public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Framework\Registry $registry,
- DateTimeFormatterInterface $dateTimeFormatter,
- array $data = []
- ) {
- $this->_registry = $registry;
- parent::__construct($context, $data);
- $this->dateTimeFormatter = $dateTimeFormatter;
- }
- /**
- * Retrieve array of tracking info
- *
- * @return array
- */
- public function getTrackingInfo()
- {
- /* @var $info \Magento\Shipping\Model\Info */
- $info = $this->_registry->registry('current_shipping_info');
- return $info->getTrackingInfo();
- }
- /**
- * Format given date and time in current locale without changing timezone
- *
- * @param string $date
- * @param string $time
- * @return string
- */
- public function formatDeliveryDateTime($date, $time)
- {
- return $this->formatDeliveryDate($date) . ' ' . $this->formatDeliveryTime($time);
- }
- /**
- * Format given date in current locale without changing timezone
- *
- * @param string $date
- * @return string
- */
- public function formatDeliveryDate($date)
- {
- $format = $this->_localeDate->getDateFormat(\IntlDateFormatter::MEDIUM);
- return $this->dateTimeFormatter->formatObject($this->_localeDate->date(new \DateTime($date)), $format);
- }
- /**
- * Format given time [+ date] in current locale without changing timezone
- *
- * @param string $time
- * @param string $date
- * @return string
- */
- public function formatDeliveryTime($time, $date = null)
- {
- if (!empty($date)) {
- $time = $date . ' ' . $time;
- }
- $format = $this->_localeDate->getTimeFormat(\IntlDateFormatter::SHORT);
- return $this->dateTimeFormatter->formatObject($this->_localeDate->date(new \DateTime($time)), $format);
- }
- /**
- * Is 'contact us' option enabled?
- *
- * @return boolean
- * @SuppressWarnings(PHPMD.BooleanGetMethodName)
- */
- public function getContactUsEnabled()
- {
- return (bool)$this->_scopeConfig->getValue(
- 'contacts/contacts/enabled',
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
- );
- }
- /**
- * @return string
- */
- public function getStoreSupportEmail()
- {
- return $this->_scopeConfig->getValue(
- 'trans_email/ident_support/email',
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
- );
- }
- /**
- * @return string
- */
- public function getContactUs()
- {
- return $this->getUrl('contact');
- }
- }
|