![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/extmag/shiplab/Block/Adminhtml/Order/View/Shipment/View/ |
<?php /** * Copyright © Extmag. All rights reserved. */ namespace Extmag\Shiplab\Block\Adminhtml\Order\View\Shipment\View; use Extmag\Shiplab\Model\Label; use Extmag\Shiplab\Model\ResourceModel\Label\Collection; use Extmag\Shiplab\Model\ResourceModel\Label\CollectionFactory; use Magento\Backend\Block\Template\Context; use Magento\Framework\Registry; use Magento\Sales\Helper\Admin; use Magento\Shipping\Model\CarrierFactory; /** * @api * @since 100.0.2 */ class Form extends \Magento\Shipping\Block\Adminhtml\View\Form { /** * @var CollectionFactory */ private $labelCollection; private $labels = []; /** * @param Context $context * @param Registry $registry * @param Admin $adminHelper * @param CarrierFactory $carrierFactory * @param CollectionFactory $labelCollection * @param array $data */ public function __construct( Context $context, Registry $registry, Admin $adminHelper, CarrierFactory $carrierFactory, CollectionFactory $labelCollection, array $data = [] ) { parent::__construct($context, $registry, $adminHelper, $carrierFactory, $data); $this->labelCollection = $labelCollection; } public function getLabels() { if (empty($this->labels)) { /** * @var Collection $collection */ $collection = $this->labelCollection->create(); $collection ->addFieldToFilter('order_sub_id', $this->getShipment()->getId()) ->addFieldToFilter('order_sub_type', 'shipment'); $this->labels = $collection; } return $this->labels; } /** * @return array */ public function getLabelsIds() { $collection = $this->getLabels(); $labelsIds = []; /** * @var Label $item */ foreach ($collection as $item) { $labelsIds[$item->getCarrierCode()]['name'] = $item->getCarrierShortName(); $labelsIds[$item->getCarrierCode()]['ids'][] = $item->getId(); } return $labelsIds; } }