Spamworldpro Mini Shell
Spamworldpro


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/Model/Source/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/extmag/shiplab/Model/Source/CarrierCodes.php
<?php
/**
 * Copyright © Extmag. All rights reserved.
 */

namespace Extmag\Shiplab\Model\Source;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Data\OptionSourceInterface;
use Magento\Framework\Module\Manager;

class CarrierCodes implements OptionSourceInterface
{
    /**
     * @var array
     */
    public $carriersData = [];

    /**
     * @var Manager
     */
    public $moduleManager;

    /**
     * @var ScopeConfigInterface
     */
    public $scopeConfig;

    /**
     * @param Manager $moduleManager
     * @param ScopeConfigInterface $scopeConfig
     */
    public function __construct(
        Manager $moduleManager,
        ScopeConfigInterface $scopeConfig
    ) {
        $this->moduleManager = $moduleManager;
        $this->scopeConfig = $scopeConfig;
    }

    /**
     * @inheritDoc
     */
    public function toOptionArray()
    {
        $configData = $this->toArray();
        $arr = [];
        foreach ($configData as $code => $title) {
            $arr[] = ['value' => $code, 'label' => $title];
        }

        return $arr;
    }

    /**
     * To Array
     *
     * @return array
     */
    public function toArray()
    {
        $arr = [];
        foreach ($this->getCarriers() as $key => $item) {
            $arr[$key] = $item['name'];
        }

        return $arr;
    }

    /**
     * Set Carriers
     *
     * @param $code
     * @param $data
     * @return void
     */
    public function setCarriers($code, $data)
    {
        $this->carriersData[strtolower($code)] = $data;
    }

    /**
     * Get Carriers
     *
     * @param $code
     * @return array|mixed
     */
    public function getCarriers($code = null)
    {
        if ($code !== null) {
            return $this->carriersData[strtolower($code)] ?? [];
        }

        return $this->carriersData;
    }
}

Spamworldpro Mini