<?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\Controller\Adminhtml;
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Backend\Model\View\Result\ForwardFactory;
use Webkul\MobikulCore\Api\Data\FeaturedcategoriesInterfaceFactory;
use Webkul\MobikulCore\Model\ResourceModel\Featuredcategories\CollectionFactory;

abstract class Featuredcategories extends \Magento\Backend\App\Action
{
    protected $date;
    protected $filter;
    protected $jsonHelper;
    protected $storeManager;
    protected $mediaDirectory;
    protected $resultPageFactory;
    protected $collectionFactory;
    protected $resultJsonFactory;
    protected $categoryRepository;
    protected $coreRegistry = null;
    protected $fileUploaderFactory;
    protected $resultForwardFactory;
    protected $categoryResourceModel;
    protected $featuredcategoriesRepository;
    protected $featuredcategoriesDataFactory;

    public function __construct(
        Filter $filter,
        Context $context,
        ForwardFactory $resultForwardFactory,
        CollectionFactory $collectionFactory,
        \Magento\Framework\Registry $coreRegistry,
        \Magento\Framework\Filesystem $filesystem,
        \Magento\Framework\Json\Helper\Data $jsonHelper,
        \Magento\Framework\Stdlib\DateTime\DateTime $date,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory,
        \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator,
        FeaturedcategoriesInterfaceFactory $featuredcategoriesDataFactory,
        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
        \Magento\Catalog\Model\ResourceModel\Category $categoryResourceModel,
        \Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository,
        \Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory,
        \Webkul\MobikulCore\Api\FeaturedcategoriesRepositoryInterface $featuredcategoriesRepository
    ) {
        parent::__construct($context);
        $this->date                          = $date;
        $this->filter                        = $filter;
        $this->jsonHelper                    = $jsonHelper;
        $this->storeManager                  = $storeManager;
        $this->coreRegistry                  = $coreRegistry;
        $this->mediaDirectory                = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
        $this->collectionFactory             = $collectionFactory;
        $this->resultJsonFactory             = $resultJsonFactory;
        $this->resultPageFactory             = $resultPageFactory;
        $this->categoryRepository            = $categoryRepository;
        $this->formKeyValidator              = $formKeyValidator;   
        $this->fileUploaderFactory           = $fileUploaderFactory;
        $this->resultForwardFactory          = $resultForwardFactory;
        $this->categoryResourceModel         = $categoryResourceModel;
        $this->featuredcategoriesRepository  = $featuredcategoriesRepository;
        $this->featuredcategoriesDataFactory = $featuredcategoriesDataFactory;
    }

    protected function _isAllowed()
    {
        return $this->_authorization->isAllowed("Webkul_MobikulCore::featuredcategories");
    }
}
