Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Data Class Reference
Inheritance diagram for Data:
AbstractHelper

Public Member Functions

 __construct (\Magento\Framework\App\Helper\Context $context, StoreManagerInterface $storeManager, UrlInterface $url=null)
 
 decodeTrackingHash ($hash)
 
 getTrackingPopupUrlBySalesModel ($model)
 
- Public Member Functions inherited from AbstractHelper
 __construct (Context $context)
 
 isModuleOutputEnabled ($moduleName=null)
 

Protected Member Functions

 _getTrackingUrl ($key, $model, $method='getId')
 
- Protected Member Functions inherited from AbstractHelper
 _getRequest ()
 
 _getModuleName ()
 
 _getUrl ($route, $params=[])
 

Protected Attributes

 $_allowedHashKeys = ['ship_id', 'order_id', 'track_id']
 
 $_storeManager
 
- Protected Attributes inherited from AbstractHelper
 $_moduleName
 
 $_request
 
 $_moduleManager
 
 $_logger
 
 $_urlBuilder
 
 $_httpHeader
 
 $_eventManager
 
 $_remoteAddress
 
 $urlEncoder
 
 $urlDecoder
 
 $scopeConfig
 
 $_cacheConfig
 

Detailed Description

Definition at line 16 of file Data.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\Helper\Context  $context,
StoreManagerInterface  $storeManager,
UrlInterface  $url = null 
)
Parameters
\Magento\Framework\App\Helper\Context$context
StoreManagerInterface$storeManager
UrlInterface | null$url

Definition at line 40 of file Data.php.

44  {
45  $this->_storeManager = $storeManager;
46  $this->url = $url ?: ObjectManager::getInstance()->get(UrlInterface::class);
47 
48  parent::__construct($context);
49  }
$storeManager

Member Function Documentation

◆ _getTrackingUrl()

_getTrackingUrl (   $key,
  $model,
  $method = 'getId' 
)
protected

Retrieve tracking url with params

Parameters
string$key

Definition at line 75 of file Data.php.

76  {
77  $urlPart = "{$key}:{$model->{$method}()}:{$model->getProtectCode()}";
78  $params = [
79  '_scope' => $model->getStoreId(),
80  '_nosid' => true,
81  '_direct' => 'shipping/tracking/popup',
82  '_query' => ['hash' => $this->urlEncoder->encode($urlPart)]
83  ];
84 
85  return $this->url->getUrl('', $params);
86  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ decodeTrackingHash()

decodeTrackingHash (   $hash)

Decode url hash

Parameters
string$hash
Returns
array

Definition at line 57 of file Data.php.

58  {
59  $hash = explode(':', $this->urlDecoder->decode($hash));
60  if (count($hash) === 3 && in_array($hash[0], $this->_allowedHashKeys)) {
61  return ['key' => $hash[0], 'id' => (int)$hash[1], 'hash' => $hash[2]];
62  }
63  return [];
64  }

◆ getTrackingPopupUrlBySalesModel()

getTrackingPopupUrlBySalesModel (   $model)

Shipping tracking popup URL getter

Parameters
\Magento\Sales\Model\AbstractModel$model
Returns
string

Definition at line 94 of file Data.php.

95  {
96  if ($model instanceof \Magento\Sales\Model\Order) {
97  return $this->_getTrackingUrl('order_id', $model);
98  } elseif ($model instanceof \Magento\Sales\Model\Order\Shipment) {
99  return $this->_getTrackingUrl('ship_id', $model);
100  } elseif ($model instanceof \Magento\Sales\Model\Order\Shipment\Track) {
101  return $this->_getTrackingUrl('track_id', $model, 'getEntityId');
102  }
103  return '';
104  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
_getTrackingUrl($key, $model, $method='getId')
Definition: Data.php:75

Field Documentation

◆ $_allowedHashKeys

$_allowedHashKeys = ['ship_id', 'order_id', 'track_id']
protected

Definition at line 23 of file Data.php.

◆ $_storeManager

$_storeManager
protected

Definition at line 28 of file Data.php.


The documentation for this class was generated from the following file: