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/wyomind/msicustomattributes/Model/CustomAttribute/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/wyomind/msicustomattributes/Model/CustomAttribute/DataProvider.php
<?php

/**
 * Copyright © 2020 Wyomind. All rights reserved.
 * See LICENSE.txt for license details.
 */
/**
 * Copyright © 2020 Wyomind. All rights reserved.
 * See LICENSE.txt for license details.
 */
namespace Wyomind\MsiCustomAttributes\Model\CustomAttribute;

class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
{
    public $customatAttributeOptionCollection;
    /**
     * @var \Wyomind\MsiCustomAttributes\Model\ResourceModel\CustomAttribute\Collection
     */
    protected $collection;
    public $dataPersistor;
    /**
     * @var array
     */
    protected $loadedData;
    public $modifiersPool;
    public $customatAttributeOptionCollectionValue;
    /**
     * @var \Wyomind\MsiCustomAttributes\Model\ResourceModel\CustomAttributeDropdownOption\Collection
     */
    protected $customAttributeOptionCollection;
    public function __construct(
        \Wyomind\MsiCustomAttributes\Helper\Delegate $wyomind,
        $name,
        $primaryFieldName,
        $requestFieldName,
        /** @delegation off */
        array $meta = [],
        array $data = []
    )
    {
        $wyomind->constructor($this, $wyomind, __CLASS__);
        parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
        $this->collection = $this->repository->list();
    }
    /**
     * Get data
     *
     * @return array
     */
    public function getData()
    {
        $customAttributesPersistor = $this->dataPersistor->get('custom_attribute');
        if ($customAttributesPersistor == null) {
            $customAttributes = $this->collection->getItems();
        } else {
            $customAttributes[] = $customAttributesPersistor;
        }
        foreach ($customAttributes as $entity) {
            $this->loadedData[$entity->getAttributeId()] = $entity->getData();
            $customAttributeOptionsPersistor = $this->dataPersistor->get('custom_attribute_options');
            if ($customAttributeOptionsPersistor == null) {
                $customAttributeDropdownOptions = $this->customatAttributeOptionCollection->getCollectionByAttributeId($entity->getAttributeId());
            } else {
                $customAttributeDropdownOptions = $customAttributeOptionsPersistor;
            }
            $i = 0;
            foreach ($customAttributeDropdownOptions as $option) {
                $data = $option->getData();
                $customAttributeDropdownOptionValues = $this->customatAttributeOptionCollectionValue->getCollectionByOptionId($option->getOptionId());
                if (isset($data["is_default"]) && $data["is_default"] == "1") {
                    $this->loadedData[$entity->getAttributeId()]["is_default"] = (string) $i;
                }
                if ($customAttributeOptionsPersistor == null) {
                    foreach ($customAttributeDropdownOptionValues as $value) {
                        $data["storeview_" . $value->getStoreId() . "_value"] = $value->getValue();
                    }
                } else {
                    $data = $data["item"];
                }
                $this->loadedData[$entity->getAttributeId()]["dynamic-rows"][] = $data;
                $i++;
            }
        }
        $this->dataPersistor->clear('custom_attribute');
        $this->dataPersistor->clear('custom_attribute_options');
        return $this->loadedData;
    }
    /**
     * @return array
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function getMeta()
    {
        $meta = parent::getMeta();
        foreach ($this->modifiersPool->getModifiersInstances() as $modifier) {
            $meta = $modifier->modifyMeta($meta);
        }
        return $meta;
    }
}

Spamworldpro Mini