Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Tracking.php
Go to the documentation of this file.
1 <?php
7 
15 {
21  protected $_coreRegistry = null;
22 
26  protected $_shippingConfig;
27 
34  public function __construct(
35  \Magento\Backend\Block\Template\Context $context,
36  \Magento\Shipping\Model\Config $shippingConfig,
37  \Magento\Framework\Registry $registry,
38  array $data = []
39  ) {
40  $this->_shippingConfig = $shippingConfig;
41  $this->_coreRegistry = $registry;
42  parent::__construct($context, $data);
43  }
44 
50  protected function _prepareLayout()
51  {
52  $this->addChild(
53  'add_button',
54  \Magento\Backend\Block\Widget\Button::class,
55  ['label' => __('Add Tracking Number'), 'class' => '', 'onclick' => 'trackingControl.add()']
56  );
57  }
58 
64  public function getShipment()
65  {
66  return $this->_coreRegistry->registry('current_shipment');
67  }
68 
74  public function getCarriers()
75  {
76  $carriers = [];
77  $carrierInstances = $this->_getCarriersInstances();
78  $carriers['custom'] = __('Custom Value');
79  foreach ($carrierInstances as $code => $carrier) {
80  if ($carrier->isTrackingAvailable()) {
81  $carriers[$code] = $carrier->getConfigData('title');
82  }
83  }
84  return $carriers;
85  }
86 
90  protected function _getCarriersInstances()
91  {
92  return $this->_shippingConfig->getAllCarriers($this->getShipment()->getStoreId());
93  }
94 }
__()
Definition: __.php:13
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Shipping\Model\Config $shippingConfig, \Magento\Framework\Registry $registry, array $data=[])
Definition: Tracking.php:34
$code
Definition: info.phtml:12