![]() 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/colissimo/module-shipping/Model/Price/ |
<?php /** * Colissimo Shipping Module * * @author Magentix * @copyright Copyright © 2018 Magentix. All rights reserved. * @license https://www.magentix.fr/en/licence.html Magentix Software Licence * @link https://colissimo.magentix.fr/ */ namespace Colissimo\Shipping\Model\Price; use Colissimo\Shipping\Model\ResourceModel\Price\Collection; use Colissimo\Shipping\Model\ResourceModel\Price\CollectionFactory; use Magento\Framework\App\Request\DataPersistorInterface; use Magento\Ui\DataProvider\AbstractDataProvider; /** * Class DataProvider */ class DataProvider extends AbstractDataProvider { /** * @var Collection $collection */ protected $collection; /** * @var DataPersistorInterface $dataPersistor */ protected $dataPersistor; /** * @var array $loadedData */ protected $loadedData; /** * @param string $name * @param string $primaryFieldName * @param string $requestFieldName * @param CollectionFactory $priceCollectionFactory * @param DataPersistorInterface $dataPersistor * @param array $meta * @param array $data */ public function __construct( $name, $primaryFieldName, $requestFieldName, CollectionFactory $priceCollectionFactory, DataPersistorInterface $dataPersistor, array $meta = [], array $data = [] ) { $this->collection = $priceCollectionFactory->create(); $this->dataPersistor = $dataPersistor; parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); $this->meta = $this->prepareMeta($this->meta); } /** * Prepares Meta * * @param array $meta * @return array */ public function prepareMeta(array $meta) { return $meta; } /** * Get data * * @return array */ public function getData() { if (isset($this->loadedData)) { return $this->loadedData; } $items = $this->collection->getItems(); /** @var $price \Colissimo\Shipping\Model\Price */ foreach ($items as $price) { $this->loadedData[$price->getId()] = $price->getData(); } $data = $this->dataPersistor->get('price'); if (!empty($data)) { $price = $this->collection->getNewEmptyItem(); $price->setData($data); $this->loadedData[$price->getId()] = $price->getData(); $this->dataPersistor->clear('price'); } return $this->loadedData; } }