Action.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Newsletter queue grid block action item renderer
  8. *
  9. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\Newsletter\Block\Adminhtml\Queue\Grid\Renderer;
  12. class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Action
  13. {
  14. /**
  15. * Renders column
  16. *
  17. * @param \Magento\Framework\DataObject $row
  18. * @return string
  19. */
  20. public function render(\Magento\Framework\DataObject $row)
  21. {
  22. $actions = [];
  23. if ($row->getQueueStatus() == \Magento\Newsletter\Model\Queue::STATUS_NEVER) {
  24. if (!$row->getQueueStartAt() && $row->getSubscribersTotal()) {
  25. $actions[] = [
  26. 'url' => $this->getUrl('*/*/start', ['id' => $row->getId()]),
  27. 'caption' => __('Start'),
  28. ];
  29. }
  30. } elseif ($row->getQueueStatus() == \Magento\Newsletter\Model\Queue::STATUS_SENDING) {
  31. $actions[] = [
  32. 'url' => $this->getUrl('*/*/pause', ['id' => $row->getId()]),
  33. 'caption' => __('Pause'),
  34. ];
  35. $actions[] = [
  36. 'url' => $this->getUrl('*/*/cancel', ['id' => $row->getId()]),
  37. 'confirm' => __('Do you really want to cancel the queue?'),
  38. 'caption' => __('Cancel'),
  39. ];
  40. } elseif ($row->getQueueStatus() == \Magento\Newsletter\Model\Queue::STATUS_PAUSE) {
  41. $actions[] = [
  42. 'url' => $this->getUrl('*/*/resume', ['id' => $row->getId()]),
  43. 'caption' => __('Resume'),
  44. ];
  45. }
  46. $actions[] = [
  47. 'url' => $this->getUrl('*/*/preview', ['id' => $row->getId()]),
  48. 'caption' => __('Preview'),
  49. 'popup' => true,
  50. ];
  51. $this->getColumn()->setActions($actions);
  52. return parent::render($row);
  53. }
  54. }