Actions.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Adminhtml AdminNotification Severity Renderer
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\AdminNotification\Block\Grid\Renderer;
  9. /**
  10. * Renderer class for action in the admin notifications grid
  11. *
  12. * @package Magento\AdminNotification\Block\Grid\Renderer
  13. */
  14. class Actions extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
  15. {
  16. /**
  17. * @var \Magento\Framework\Url\Helper\Data
  18. */
  19. protected $_urlHelper;
  20. /**
  21. * @param \Magento\Backend\Block\Context $context
  22. * @param \Magento\Framework\Url\Helper\Data $urlHelper
  23. * @param array $data
  24. */
  25. public function __construct(
  26. \Magento\Backend\Block\Context $context,
  27. \Magento\Framework\Url\Helper\Data $urlHelper,
  28. array $data = []
  29. ) {
  30. $this->_urlHelper = $urlHelper;
  31. parent::__construct($context, $data);
  32. }
  33. /**
  34. * Renders grid column
  35. *
  36. * @param \Magento\Framework\DataObject $row
  37. * @return string
  38. */
  39. public function render(\Magento\Framework\DataObject $row)
  40. {
  41. $readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' .
  42. $this->escapeUrl($row->getUrl())
  43. . '">' .
  44. __('Read Details') . '</a>' : '';
  45. $markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl(
  46. '*/*/markAsRead/',
  47. ['_current' => true, 'id' => $row->getId()]
  48. ) . '">' . __(
  49. 'Mark as Read'
  50. ) . '</a>' : '';
  51. $encodedUrl = $this->_urlHelper->getEncodedUrl();
  52. return sprintf(
  53. '%s%s<a class="action-delete" href="%s" onClick="deleteConfirm(\'%s\', this.href); return false;">%s</a>',
  54. $readDetailsHtml,
  55. $markAsReadHtml,
  56. $this->getUrl(
  57. '*/*/remove/',
  58. [
  59. '_current' => true,
  60. 'id' => $row->getId(),
  61. \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl
  62. ]
  63. ),
  64. __('Are you sure?'),
  65. __('Remove')
  66. );
  67. }
  68. }