Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Track.php
Go to the documentation of this file.
1 <?php
8 
10 
23 class Track extends \Magento\Sales\Model\Order\Shipment\Track
24 {
28  protected $_carrierFactory;
29 
44  public function __construct(
45  \Magento\Framework\Model\Context $context,
46  \Magento\Framework\Registry $registry,
47  \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
49  \Magento\Store\Model\StoreManagerInterface $storeManager,
51  \Magento\Shipping\Model\CarrierFactory $carrierFactory,
52  \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
53  \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
54  array $data = []
55  ) {
56  parent::__construct(
57  $context,
58  $registry,
59  $extensionFactory,
63  $resource,
64  $resourceCollection,
65  $data
66  );
67  $this->_carrierFactory = $carrierFactory;
68  }
69 
75  public function getNumberDetail()
76  {
77  $carrierInstance = $this->_carrierFactory->create($this->getCarrierCode());
78  if (!$carrierInstance) {
79  $custom = [];
80  $custom['title'] = $this->getTitle();
81  $custom['number'] = $this->getTrackNumber();
82  return $custom;
83  } else {
84  $carrierInstance->setStore($this->getStore());
85  }
86 
87  $trackingInfo = $carrierInstance->getTrackingInfo($this->getNumber());
88  if (!$trackingInfo) {
89  return __('No detail for number "%1"', $this->getNumber());
90  }
91 
92  return $trackingInfo;
93  }
94 }
$storeManager
__()
Definition: __.php:13
$resource
Definition: bulk.php:12
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Sales\Api\ShipmentRepositoryInterface $shipmentRepository, \Magento\Shipping\Model\CarrierFactory $carrierFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
Definition: Track.php:44