![]() 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/cartforge.co/app/code/Webkul/PrivateShop/Model/EmailForm/ |
<?php /** * Webkul Software * * @category Webkul * @package Webkul_PrivateShop * @author Webkul Software Private Limited * @copyright Webkul Software Private Limited (https://webkul.com) * @license https://store.webkul.com/license.html */ namespace Webkul\PrivateShop\Model\EmailForm; use Webkul\PrivateShop\Model\ResourceModel\PrivateGroup\CollectionFactory; use Webkul\PrivateShop\Model\ResourceModel\Queue\Message\CollectionFactory as MessageFactory; use Magento\Framework\App\Request\DataPersistorInterface; class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider { /** * @var DataProvider */ protected $loadedData; /** * @var Webkul\PrivateShop\Model\ResourceModel\PrivateGroup\Collection */ protected $collection; /** * @var DataPersistorInterface */ protected $dataPersistor; /** * @var MessageFactory */ protected $messageFactory; /** * Constructor * * @param string $name * @param string $primaryFieldName * @param string $requestFieldName * @param CollectionFactory $collectionFactory * @param MessageFactory $messageFactory * @param DataPersistorInterface $dataPersistor * @param array $meta * @param array $data */ public function __construct( $name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, MessageFactory $messageFactory, DataPersistorInterface $dataPersistor, array $meta = [], array $data = [] ) { $this->collection = $collectionFactory->create(); $this->messageFactory = $messageFactory; $this->dataPersistor = $dataPersistor; parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); } /** * Get data * * @return array */ public function getData() { if (isset($this->loadedData)) { return $this->loadedData; } $data = $this->dataPersistor->get('group'); if (!empty($data) && $data['group_id'] != 0) { $collection = $this->messageFactory->create() ->addFieldToFilter('entity_id', $data['group_id']) ->setCurPage(1) ->setPageSize(1); $content = ""; $subject = ""; $groupId = ""; foreach ($collection as $_collection) { $message = $_collection->getMessageContent(); $message = json_decode($message, true); $content = $message['content']; $subject = $message['subject']; $groupId = $message['group_id']; } $this->loadedData[$data['group_id']]['groups'] = $groupId; $this->loadedData[$data['group_id']]['subject'] = $subject; $this->loadedData[$data['group_id']]['body'] = $content; $this->loadedData[$data['group_id']]['entity'] = $data['group_id']; } $this->dataPersistor->clear('group'); return $this->loadedData; } }