Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
View.php
Go to the documentation of this file.
1 <?php
7 
15 {
19  protected $_carrierFactory;
20 
28  public function __construct(
29  \Magento\Backend\Block\Template\Context $context,
30  \Magento\Shipping\Model\Config $shippingConfig,
31  \Magento\Framework\Registry $registry,
32  \Magento\Shipping\Model\CarrierFactory $carrierFactory,
33  array $data = []
34  ) {
35  parent::__construct($context, $shippingConfig, $registry, $data);
36  $this->_carrierFactory = $carrierFactory;
37  }
38 
44  protected function _prepareLayout()
45  {
46  $onclick = "submitAndReloadArea($('shipment_tracking_info').parentNode, '" . $this->getSubmitUrl() . "')";
47  $this->addChild(
48  'save_button',
49  \Magento\Backend\Block\Widget\Button::class,
50  ['label' => __('Add'), 'class' => 'save', 'onclick' => $onclick]
51  );
52  }
53 
59  public function getSubmitUrl()
60  {
61  return $this->getUrl('adminhtml/*/addTrack/', ['shipment_id' => $this->getShipment()->getId()]);
62  }
63 
69  public function getSaveButtonHtml()
70  {
71  return $this->getChildHtml('save_button');
72  }
73 
80  public function getRemoveUrl($track)
81  {
82  return $this->getUrl(
83  'adminhtml/*/removeTrack/',
84  ['shipment_id' => $this->getShipment()->getId(), 'track_id' => $track->getId()]
85  );
86  }
87 
92  public function getCarrierTitle($code)
93  {
94  $carrier = $this->_carrierFactory->create($code);
95  return $carrier ? $carrier->getConfigData('title') : __('Custom Value');
96  }
97 }
$track
Definition: details.phtml:12
__()
Definition: __.php:13
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Shipping\Model\Config $shippingConfig, \Magento\Framework\Registry $registry, \Magento\Shipping\Model\CarrierFactory $carrierFactory, array $data=[])
Definition: View.php:28
$code
Definition: info.phtml:12