![]() 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/ConfigurationStore/ |
<?php /** * Copyright © Extmag. All rights reserved. */ namespace Extmag\Shiplab\Model\ConfigurationStore; use Extmag\Shiplab\Model\ConfigurationStore; use Extmag\Shiplab\Model\ResourceModel\ConfigurationStore\Collection; use Extmag\Shiplab\Model\ResourceModel\ConfigurationStore\CollectionFactory; use Magento\Framework\App\Request\DataPersistorInterface; use Magento\Ui\DataProvider\Modifier\PoolInterface; use Magento\Ui\DataProvider\ModifierPoolDataProvider; class DataProvider extends ModifierPoolDataProvider { /** * @var Collection */ protected $collection; /** * @var DataPersistorInterface */ protected $dataPersistor; /** * @var array */ protected $loadedData; /** * @param string $name * @param string $primaryFieldName * @param string $requestFieldName * @param CollectionFactory $configurationStoreCollectionFactory * @param DataPersistorInterface $dataPersistor * @param array $meta * @param array $data * @param PoolInterface|null $pool */ public function __construct( $name, $primaryFieldName, $requestFieldName, CollectionFactory $configurationStoreCollectionFactory, DataPersistorInterface $dataPersistor, array $meta = [], array $data = [], PoolInterface $pool = null ) { $this->collection = $configurationStoreCollectionFactory->create(); $this->dataPersistor = $dataPersistor; parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool); $this->meta = $this->prepareMeta($this->meta); } /** * @param array $meta * @return array */ public function prepareMeta(array $meta) { return $meta; } /** * @return array */ public function getData() { if (isset($this->loadedData)) { return $this->loadedData; } $items = $this->collection->getItems(); /** @var $page ConfigurationStore */ foreach ($items as $page) { $this->loadedData[$page->getId()] = $page->getData(); } $data = $this->dataPersistor->get('extmag_shiplab_configurationstore'); if (!empty($data)) { $page = $this->collection->getNewEmptyItem(); $page->setData($data); $this->loadedData[$page->getId()] = $page->getData(); $this->dataPersistor->clear('extmag_shiplab_configurationstore'); } return $this->loadedData; } }