12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Shipping\Block\Adminhtml\Order;
- /**
- * Shipment tracking control form
- *
- * @api
- * @since 100.0.2
- */
- class Tracking extends \Magento\Backend\Block\Template
- {
- /**
- * Core registry
- *
- * @var \Magento\Framework\Registry
- */
- protected $_coreRegistry = null;
- /**
- * @var \Magento\Shipping\Model\Config
- */
- protected $_shippingConfig;
- /**
- * @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Shipping\Model\Config $shippingConfig
- * @param \Magento\Framework\Registry $registry
- * @param array $data
- */
- public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Shipping\Model\Config $shippingConfig,
- \Magento\Framework\Registry $registry,
- array $data = []
- ) {
- $this->_shippingConfig = $shippingConfig;
- $this->_coreRegistry = $registry;
- parent::__construct($context, $data);
- }
- /**
- * Prepares layout of block
- *
- * @return void
- */
- protected function _prepareLayout()
- {
- $this->addChild(
- 'add_button',
- \Magento\Backend\Block\Widget\Button::class,
- ['label' => __('Add Tracking Number'), 'class' => '', 'onclick' => 'trackingControl.add()']
- );
- }
- /**
- * Retrieve shipment model instance
- *
- * @return \Magento\Sales\Model\Order\Shipment
- */
- public function getShipment()
- {
- return $this->_coreRegistry->registry('current_shipment');
- }
- /**
- * Retrieve carriers
- *
- * @return array
- */
- public function getCarriers()
- {
- $carriers = [];
- $carrierInstances = $this->_getCarriersInstances();
- $carriers['custom'] = __('Custom Value');
- foreach ($carrierInstances as $code => $carrier) {
- if ($carrier->isTrackingAvailable()) {
- $carriers[$code] = $carrier->getConfigData('title');
- }
- }
- return $carriers;
- }
- /**
- * @return array
- */
- protected function _getCarriersInstances()
- {
- return $this->_shippingConfig->getAllCarriers($this->getShipment()->getStoreId());
- }
- }
|