Action.php 1.94 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * Newsletter queue grid block action item renderer
 *
 * @author      Magento Core Team <core@magentocommerce.com>
 */
namespace Magento\Newsletter\Block\Adminhtml\Queue\Grid\Renderer;

class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Action
{
    /**
     * Renders column
     *
     * @param \Magento\Framework\DataObject $row
     * @return string
     */
    public function render(\Magento\Framework\DataObject $row)
    {
        $actions = [];

        if ($row->getQueueStatus() == \Magento\Newsletter\Model\Queue::STATUS_NEVER) {
            if (!$row->getQueueStartAt() && $row->getSubscribersTotal()) {
                $actions[] = [
                    'url' => $this->getUrl('*/*/start', ['id' => $row->getId()]),
                    'caption' => __('Start'),
                ];
            }
        } elseif ($row->getQueueStatus() == \Magento\Newsletter\Model\Queue::STATUS_SENDING) {
            $actions[] = [
                'url' => $this->getUrl('*/*/pause', ['id' => $row->getId()]),
                'caption' => __('Pause'),
            ];

            $actions[] = [
                'url' => $this->getUrl('*/*/cancel', ['id' => $row->getId()]),
                'confirm' => __('Do you really want to cancel the queue?'),
                'caption' => __('Cancel'),
            ];
        } elseif ($row->getQueueStatus() == \Magento\Newsletter\Model\Queue::STATUS_PAUSE) {
            $actions[] = [
                'url' => $this->getUrl('*/*/resume', ['id' => $row->getId()]),
                'caption' => __('Resume'),
            ];
        }

        $actions[] = [
            'url' => $this->getUrl('*/*/preview', ['id' => $row->getId()]),
            'caption' => __('Preview'),
            'popup' => true,
        ];

        $this->getColumn()->setActions($actions);
        return parent::render($row);
    }
}