<?php

namespace PortalPeople\DisabledDates\Controller\Adminhtml\Date;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;

class NewAction extends Action
{
    protected $resultPageFactory;

    public function __construct(
        Context $context,
        PageFactory $resultPageFactory
    ) {
        parent::__construct($context);
        $this->resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
        // Create new empty model and register it
        $model = $this->_objectManager->create(\PortalPeople\DisabledDates\Model\DisabledDate::class);
        $this->_objectManager->get(\Magento\Framework\Registry::class)->register('disableddates_date', $model);

        $resultPage = $this->resultPageFactory->create();
        $resultPage->setActiveMenu('PortalPeople_DisabledDates::disabled_dates');
        $resultPage->getConfig()->getTitle()->prepend(__('Add New Disabled Date'));
        
        return $resultPage;
    }

    protected function _isAllowed()
    {
        return $this->_authorization->isAllowed('PortalPeople_DisabledDates::disabled_dates');
    }
}
