Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Unassign.php
Go to the documentation of this file.
1 <?php
7 
9 use \Magento\Backend\Block\Template\Context;
11 
16 class Unassign extends \Magento\Backend\Block\Widget\Grid\Column
17 {
21  private $json;
22 
28  public function __construct(
29  Context $context,
30  array $data = [],
31  ?Json $json = null
32  ) {
33  parent::__construct($context, $data);
34  $this->json = $json ?? ObjectManager::getInstance()->get(Json::class);
35  }
36 
42  public function getFrameCallback()
43  {
44  return [$this, 'decorateAction'];
45  }
46 
57  public function decorateAction($value, $row, $column, $isExport)
58  {
59  $cell = '';
60  $state = $row->getState();
61  if (!empty($state)) {
62  $url = $this->getUrl('*/*/unassign');
63  $label = __('Unassign');
64  $cell = '<a href="#" data-post="'
65  .$this->escapeHtmlAttr(
66  $this->json->serialize([
67  'action' => $url,
68  'data' => ['status' => $row->getStatus(), 'state' => $row->getState()]
69  ])
70  )
71  .'">' . $label . '</a>';
72  }
73  return $cell;
74  }
75 }
__()
Definition: __.php:13
$label
Definition: details.phtml:21
decorateAction($value, $row, $column, $isExport)
Definition: Unassign.php:57
$value
Definition: gender.phtml:16
__construct(Context $context, array $data=[], ?Json $json=null)
Definition: Unassign.php:28