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/Ecombricks/InventoryInventoryCatalog/Model/SourceItemOption/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/Ecombricks/InventoryInventoryCatalog/Model/SourceItemOption/Get.php
<?php
/**
 * Copyright © eComBricks. All rights reserved.
 * See LICENSE.txt for license details.
 */
declare(strict_types=1);

namespace Ecombricks\InventoryInventoryCatalog\Model\SourceItemOption;

/**
 * Get source item options
 */
class Get implements \Ecombricks\InventoryInventoryCatalog\Api\SourceItemOption\GetInterface
{
    
    /**
     * Resource
     * 
     * @var \Ecombricks\InventoryInventoryCatalog\Model\ResourceModel\SourceItemOption\Get
     */
    protected $resource;
    
    /**
     * Source item option factory
     * 
     * @var \Ecombricks\InventoryInventoryCatalog\Api\Data\SourceItemOptionInterfaceFactory
     */
    protected $sourceItemOptionFactory;
    
    /**
     * Data object helper
     * 
     * @var \Magento\Framework\Api\DataObjectHelper
     */
    protected $dataObjectHelper;
    
    /**
     * Source item option label
     * 
     * @var \Ecombricks\InventoryInventoryCatalog\Model\SourceItemOption\Label
     */
    protected $sourceItemOptionLabel;
    
    /**
     * Constructor
     * 
     * @param \Ecombricks\InventoryInventoryCatalog\Model\ResourceModel\SourceItemOption\Get $resource
     * @param \Ecombricks\InventoryInventoryCatalog\Api\Data\SourceItemOptionInterfaceFactory $sourceItemOptionFactory
     * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
     * @param \Ecombricks\InventoryInventoryCatalog\Model\SourceItemOption\Label $sourceItemOptionLabel
     * @return void
     */
    public function __construct(
        \Ecombricks\InventoryInventoryCatalog\Model\ResourceModel\SourceItemOption\Get $resource,
        \Ecombricks\InventoryInventoryCatalog\Api\Data\SourceItemOptionInterfaceFactory $sourceItemOptionFactory,
        \Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
        \Ecombricks\InventoryInventoryCatalog\Model\SourceItemOption\Label $sourceItemOptionLabel
    )
    {
        $this->resource = $resource;
        $this->sourceItemOptionFactory = $sourceItemOptionFactory;
        $this->dataObjectHelper = $dataObjectHelper;
        $this->sourceItemOptionLabel = $sourceItemOptionLabel;
    }
    
    /**
     * Execute
     * 
     * @param array $skus
     * @param array $sourceCodes
     * @return array
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function execute(array $skus, array $sourceCodes): array
    {
        if (empty($skus) || empty($sourceCodes)) {
            throw new \Magento\Framework\Exception\InputException(__('No SKUs or source codes provided for the %1.', $this->sourceItemOptionLabel->renderPlural()));
        }
        $sourceItemOptionsData = $this->resource->execute($skus, $sourceCodes);
        if (empty($sourceItemOptionsData)) {
            return [];
        }
        $sourceItemOptions = [];
        foreach ($sourceItemOptionsData as $sourceItemOptionData) {
            $sourceItemOption = $this->sourceItemOptionFactory->create();
            $this->dataObjectHelper->populateWithArray(
                $sourceItemOption,
                $sourceItemOptionData,
                \Ecombricks\InventoryInventoryCatalog\Api\Data\SourceItemOptionInterface::class
            );
            $sourceItemOptions[$sourceItemOption->getSku()][$sourceItemOption->getSourceCode()] = $sourceItemOption;
        }
        return $sourceItemOptions;
    }
    
}

Spamworldpro Mini