<?php
/**
 * Webkul Software.
 * 
 * PHP version 7.0+
 *
 * @category  Webkul
 * @package   Webkul_MobikulCore
 * @author    Webkul <support@webkul.com>
 * @copyright 2010-2019 Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html ASL Licence
 * @link      https://store.webkul.com/license.html
 */

namespace Webkul\MobikulCore\Ui\Component\Listing\Column;

use Magento\Framework\Escaper;
use Magento\Store\Model\System\Store as SystemStore;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Framework\View\Element\UiComponent\ContextInterface;

/**
 * Class Totals in Sales Order Block
 */
class Store extends \Magento\Store\Ui\Component\Listing\Column\Store
{

    protected $request;

    /**
     * @param \Magento\Framework\App\Request\Http $request            request
     * @param ContextInterface                    $context            context
     * @param UiComponentFactory                  $uiComponentFactory uiComponentFactory
     * @param SystemStore                         $systemStore        systemStore
     * @param Escaper                             $escaper            escaper
     * @param array                               $components         components
     * @param array                               $data               data
     * @param storeKey                                                storeKey
     */
    public function __construct(
        \Magento\Framework\App\Request\Http $request,
        ContextInterface $context,
        UiComponentFactory $uiComponentFactory,
        SystemStore $systemStore,
        Escaper $escaper,
        array $components = [],
        array $data = []
    ) {
        $this->request = $request;
        parent::__construct($context, $uiComponentFactory, $systemStore, $escaper, $components, $data, 'store_id');
    }

    /**
     * Fucntion to prepareItem
     *
     * @param array $item item
     *
     * @return parent prepareItem
     */
    protected function prepareItem(array $item)
    {
        if ($this->request->getParam("namespace") == "mobikul_notification_list" && is_string($item[$this->storeKey])) {
            $item[$this->storeKey] = explode(",", $item[$this->storeKey]);
        }
        return parent::prepareItem($item);
    }

}