Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Grid.php
Go to the documentation of this file.
1 <?php
7 
15 class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
16 {
22  protected $_coreRegistry = null;
23 
30 
38  public function __construct(
39  \Magento\Backend\Block\Template\Context $context,
40  \Magento\Backend\Helper\Data $backendHelper,
41  \Magento\Framework\Data\CollectionFactory $collectionFactory,
42  \Magento\Framework\Registry $coreRegistry,
43  array $data = []
44  ) {
45  $this->_collectionFactory = $collectionFactory;
46  $this->_coreRegistry = $coreRegistry;
47  parent::__construct($context, $backendHelper, $data);
48  }
49 
55  protected function _construct()
56  {
57  $this->setId('transactionDetailsGrid');
58  $this->setPagerVisibility(false);
59  $this->setFilterVisibility(false);
60  }
61 
67  protected function _prepareCollection()
68  {
69  $collection = $this->_collectionFactory->create();
70  foreach ($this->getTransactionAdditionalInfo() as $key => $value) {
71  $data = new \Magento\Framework\DataObject(['key' => $key, 'value' => $value]);
72  $collection->addItem($data);
73  }
74 
75  $this->setCollection($collection);
76  return parent::_prepareCollection();
77  }
78 
84  protected function _prepareColumns()
85  {
86  $this->addColumn(
87  'key',
88  [
89  'header' => __('Key'),
90  'index' => 'key',
91  'sortable' => false,
92  'type' => 'text',
93  'header_css_class' => 'col-key',
94  'column_css_class' => 'col-key'
95  ]
96  );
97 
98  $this->addColumn(
99  'value',
100  [
101  'header' => __('Value'),
102  'index' => 'value',
103  'sortable' => false,
104  'type' => 'text',
105  'escape' => true,
106  'header_css_class' => 'col-value',
107  'column_css_class' => 'col-value'
108  ]
109  );
110 
111  return parent::_prepareColumns();
112  }
113 
120  {
121  $info = $this->_coreRegistry->registry(
122  'current_transaction'
123  )->getAdditionalInformation(
124  \Magento\Sales\Model\Order\Payment\Transaction::RAW_DETAILS
125  );
126  return is_array($info) ? $info : [];
127  }
128 }
__()
Definition: __.php:13
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, \Magento\Framework\Data\CollectionFactory $collectionFactory, \Magento\Framework\Registry $coreRegistry, array $data=[])
Definition: Grid.php:38
$value
Definition: gender.phtml:16
setPagerVisibility($visible=true)
Definition: Grid.php:588
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52