12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Shipping\Block\Adminhtml\Order\Tracking;
- /**
- * Shipment tracking control form
- *
- * @api
- * @since 100.0.2
- */
- class View extends \Magento\Shipping\Block\Adminhtml\Order\Tracking
- {
- /**
- * @var \Magento\Shipping\Model\CarrierFactory
- */
- protected $_carrierFactory;
- /**
- * @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Shipping\Model\Config $shippingConfig
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Shipping\Model\CarrierFactory $carrierFactory
- * @param array $data
- */
- public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Shipping\Model\Config $shippingConfig,
- \Magento\Framework\Registry $registry,
- \Magento\Shipping\Model\CarrierFactory $carrierFactory,
- array $data = []
- ) {
- parent::__construct($context, $shippingConfig, $registry, $data);
- $this->_carrierFactory = $carrierFactory;
- }
- /**
- * Prepares layout of block
- *
- * @return void
- */
- protected function _prepareLayout()
- {
- $onclick = "submitAndReloadArea($('shipment_tracking_info').parentNode, '" . $this->getSubmitUrl() . "')";
- $this->addChild(
- 'save_button',
- \Magento\Backend\Block\Widget\Button::class,
- ['label' => __('Add'), 'class' => 'save', 'onclick' => $onclick]
- );
- }
- /**
- * Retrieve save url
- *
- * @return string
- */
- public function getSubmitUrl()
- {
- return $this->getUrl('adminhtml/*/addTrack/', ['shipment_id' => $this->getShipment()->getId()]);
- }
- /**
- * Retrieve save button html
- *
- * @return string
- */
- public function getSaveButtonHtml()
- {
- return $this->getChildHtml('save_button');
- }
- /**
- * Retrieve remove url
- *
- * @param \Magento\Sales\Model\Order\Shipment\Track $track
- * @return string
- */
- public function getRemoveUrl($track)
- {
- return $this->getUrl(
- 'adminhtml/*/removeTrack/',
- ['shipment_id' => $this->getShipment()->getId(), 'track_id' => $track->getId()]
- );
- }
- /**
- * @param string $code
- * @return \Magento\Framework\Phrase|string|bool
- */
- public function getCarrierTitle($code)
- {
- $carrier = $this->_carrierFactory->create($code);
- return $carrier ? $carrier->getConfigData('title') : __('Custom Value');
- }
- }
|