<?php
/**
 * Mageplaza
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Mageplaza.com license that is
 * available through the world-wide-web at this URL:
 * https://www.mageplaza.com/LICENSE.txt
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category    Mageplaza
 * @package     Mageplaza_EditOrder
 * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
 * @license     https://www.mageplaza.com/LICENSE.txt
 */

namespace Mageplaza\EditOrder\Block\Adminhtml\Config;

use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field as FormField;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Module\FullModuleList;

/**
 * Class DeleteOrder
 * @package Mageplaza\EditOrder\Block\Adminhtml\Config
 */
class DeleteOrder extends FormField
{
    /**
     * @var
     */
    protected $element;

    /**
     * @var FullModuleList
     */
    protected $moduleList;

    /**
     * DeleteOrder constructor.
     *
     * @param Context $context
     * @param FullModuleList $moduleList
     * @param array $data
     */
    public function __construct(
        Context $context,
        FullModuleList $moduleList,
        array $data = []
    ) {
        $this->moduleList =$moduleList;
        parent::__construct($context, $data);
    }

    /**
     * @inheritdoc
     */
    protected function _construct()
    {
        $this->setTemplate('Mageplaza_EditOrder::config/deleteOrder.phtml');
        parent::_construct();
    }

    /**
     * Return element html
     *
     * @param AbstractElement $element
     *
     * @return string
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    protected function _getElementHtml(AbstractElement $element)
    {
        $this->element = $element;

        return $this->_toHtml();
    }

    /**
     *
     * @return boolean
     */
    public function checkModuleDeleteOrder()
    {
        return $this->moduleList->has('Mageplaza_DeleteOrders');
    }
}
