Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Multiaction.php
Go to the documentation of this file.
1 <?php
7 
13 class Multiaction extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Action
14 {
21  public function render(\Magento\Framework\DataObject $row)
22  {
23  $html = '';
24  $actions = $this->getColumn()->getActions();
25  if (!empty($actions) && is_array($actions)) {
26  $links = [];
27  foreach ($actions as $action) {
28  if (is_array($action)) {
29  $link = $this->_toLinkHtml($action, $row);
30  if ($link) {
31  $links[] = $link;
32  }
33  }
34  }
35  $html = implode('<br />', $links);
36  }
37 
38  if ($html == '') {
39  $html = '&nbsp;';
40  }
41 
42  return $html;
43  }
44 
52  protected function _toLinkHtml($action, \Magento\Framework\DataObject $row)
53  {
54  $product = $row->getProduct();
55 
56  if (isset($action['process']) && $action['process'] == 'configurable') {
57  if ($product->canConfigure()) {
58  $style = '';
59  $onClick = sprintf('onclick="return %s.configureItem(%s)"', $action['control_object'], $row->getId());
60  return sprintf('<a href="%s" %s %s>%s</a>', $action['url'], $style, $onClick, $action['caption']);
61  } else {
62  return false;
63  }
64  } else {
65  return parent::_toLinkHtml($action, $row);
66  }
67  }
68 }
_toLinkHtml($action, \Magento\Framework\DataObject $row)
Definition: Multiaction.php:52