<?php
/**
* Landofcoder
*
* NOTICE OF LICENSE
*
* This source file is subject to the Landofcoder.com license that is
* available through the world-wide-web at this URL:
* https://landofcoder.com/terms
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Landofcoder
* @package Lof_MarketPlace
* @copyright Copyright (c) 2021 Landofcoder (https://www.landofcoder.com/)
* @license https://landofcoder.com/terms
*/
namespace Lof\MarketPlace\Model\Vacation;
use Lof\MarketPlace\Model\ResourceModel\Vacation\CollectionFactory;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Registry;
class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
{
protected $collection;
protected $dataPersistor;
protected $loadedData;
/**
* @var Registry
*/
protected $coreRegistry;
/**
* Constructor
*
* @param string $name
* @param string $primaryFieldName
* @param string $requestFieldName
* @param CollectionFactory $collectionFactory
* @param DataPersistorInterface $dataPersistor
* @param Registry $coreRegistry
* @param array $meta
* @param array $data
*/
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $collectionFactory,
DataPersistorInterface $dataPersistor,
Registry $coreRegistry,
array $meta = [],
array $data = []
) {
$this->collection = $collectionFactory->create();
$this->dataPersistor = $dataPersistor;
$this->coreRegistry = $coreRegistry;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
}
/**
* Get data
*
* @return array
*/
public function getData()
{
if (isset($this->loadedData)) {
return $this->loadedData;
}
$currentModel = $this->coreRegistry->registry('current_model');
if ($currentModel && $currentModel->getId()) {
$this->loadedData[$currentModel->getId()] = $currentModel->getData();
}
return $this->loadedData;
}
}
|