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/amasty/feed/Model/Field/DataProvider/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/amasty/feed/Model/Field/DataProvider/Form.php
<?php
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Product Feed for Magento 2
 */

namespace Amasty\Feed\Model\Field\DataProvider;

use Amasty\Feed\Block\Adminhtml\Field\Edit\Conditions;
use Amasty\Feed\Model\Field\ResourceModel\CollectionFactory;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Ui\DataProvider\AbstractDataProvider;

class Form extends AbstractDataProvider
{
    /**
     * @var DataPersistorInterface
     */
    private $dataPersistor;

    public function __construct(
        $name,
        $primaryFieldName,
        $requestFieldName,
        CollectionFactory $collectionFactory,
        DataPersistorInterface $dataPersistor,
        array $meta = [],
        array $data = []
    ) {
        $this->dataPersistor = $dataPersistor;
        $this->collection = $collectionFactory->create();
        parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
    }

    /**
     * @return array
     *
     * Used to process data of fieldset "field_general"
     */
    public function getData(): array
    {
        $data = [];
        $item = parent::getData()['items'][0] ?? null;
        if ($item) {
            $data[$item[$this->primaryFieldName]] = $item;
        }
        $this->restoreUnsavedData($data);

        return $data;
    }

    /**
     * Try to get unsaved data if error was occurred.
     *
     * @param array $data
     */
    private function restoreUnsavedData(array &$data)
    {
        $tempData = $this->dataPersistor->get(Conditions::FORM_NAMESPACE);
        if ($tempData) {
            /** @var \Amasty\Feed\Model\Field\Field $tempModel */
            $tempModel = $this->collection->getNewEmptyItem();
            $tempModel->setData($tempData);
            $data[$tempModel->getId()] = $tempModel->getData();
            $this->dataPersistor->clear(Conditions::FORM_NAMESPACE);
        }
    }
}

Spamworldpro Mini