![]() 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/ |
<?php /** * Copyright © Extmag. All rights reserved. */ namespace Extmag\Shiplab\Block\Adminhtml\Order\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\Exception\LocalizedException; use Magento\Framework\Registry; use Magento\Sales\Helper\Admin; class AbstractOrder extends \Magento\Sales\Block\Adminhtml\Order\AbstractOrder { /** * @var CollectionFactory */ private $labelCollection; /** * @var Label[] */ private $labels = []; /** * @param Context $context * @param Registry $registry * @param Admin $adminHelper * @param array $data * @param CollectionFactory $labelCollection */ public function __construct( Context $context, Registry $registry, Admin $adminHelper, CollectionFactory $labelCollection, array $data = [] ) { parent::__construct($context, $registry, $adminHelper, $data); $this->labelCollection = $labelCollection; } /** * @throws LocalizedException */ public function getLabels() { if (empty($this->labels)) { /** * @var Collection $collection */ $collection = $this->labelCollection->create(); $collection ->addFieldToFilter('order_sub_id', $this->getOrder()->getId()) ->addFieldToFilter('order_sub_type', 'order'); $this->labels = $collection; } return $this->labels; } public function getLabelsIds() { /** * @var Collection $collection */ $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; } }