Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Actions.php
Go to the documentation of this file.
1 <?php
10 
11 class Actions extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
12 {
16  protected $_urlHelper;
17 
23  public function __construct(
24  \Magento\Backend\Block\Context $context,
25  \Magento\Framework\Url\Helper\Data $urlHelper,
26  array $data = []
27  ) {
28  $this->_urlHelper = $urlHelper;
29  parent::__construct($context, $data);
30  }
31 
38  public function render(\Magento\Framework\DataObject $row)
39  {
40  $readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' . $row->getUrl() . '">' .
41  __('Read Details') . '</a>' : '';
42 
43  $markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl(
44  '*/*/markAsRead/',
45  ['_current' => true, 'id' => $row->getId()]
46  ) . '">' . __(
47  'Mark as Read'
48  ) . '</a>' : '';
49 
50  $encodedUrl = $this->_urlHelper->getEncodedUrl();
51  return sprintf(
52  '%s%s<a class="action-delete" href="%s" onClick="deleteConfirm(\'%s\', this.href); return false;">%s</a>',
53  $readDetailsHtml,
54  $markAsReadHtml,
55  $this->getUrl(
56  '*/*/remove/',
57  [
58  '_current' => true,
59  'id' => $row->getId(),
61  ]
62  ),
63  __('Are you sure?'),
64  __('Remove')
65  );
66  }
67 }
__()
Definition: __.php:13
render(\Magento\Framework\DataObject $row)
Definition: Actions.php:38
__construct(\Magento\Backend\Block\Context $context, \Magento\Framework\Url\Helper\Data $urlHelper, array $data=[])
Definition: Actions.php:23