<?php
namespace PortalPeople\DisabledDates\Block\Adminhtml\Date\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
use Magento\Framework\UrlInterface;
use Magento\Framework\App\RequestInterface;

class DeleteButton implements ButtonProviderInterface
{
    protected $urlBuilder;
    protected $request;

    public function __construct(
        UrlInterface $urlBuilder,
        RequestInterface $request
    ) {
        $this->urlBuilder = $urlBuilder;
        $this->request = $request;
    }

    public function getButtonData()
    {
        $data = [];
        if ($this->request->getParam('entity_id')) {
            $data = [
                'label' => __('Delete'),
                'class' => 'delete',
                'on_click' => 'deleteConfirm(\'' . __(
                    'Are you sure you want to delete this date?'
                ) . '\', \'' . $this->urlBuilder->getUrl('*/*/delete', ['entity_id' => $this->request->getParam('entity_id')]) . '\')',
                'sort_order' => 20,
            ];
        }
        return $data;
    }
}
