Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Payment.php
Go to the documentation of this file.
1 <?php
7 
9 
18 {
24  protected $_paymentData = null;
25 
31  public function __construct(
32  \Magento\Backend\Block\Template\Context $context,
33  \Magento\Payment\Helper\Data $paymentData,
34  array $data = []
35  ) {
36  $this->_paymentData = $paymentData;
37  parent::__construct($context, $data);
38  }
39 
46  protected function _beforeToHtml()
47  {
48  if (!$this->getParentBlock()) {
49  throw new \Magento\Framework\Exception\LocalizedException(__('Invalid parent block for this block'));
50  }
51  $this->setPayment($this->getParentBlock()->getOrder()->getPayment());
52  parent::_beforeToHtml();
53  }
54 
61  public function setPayment($payment)
62  {
63  $paymentInfoBlock = $this->_paymentData->getInfoBlock($payment, $this->getLayout());
64  $this->setChild('info', $paymentInfoBlock);
65  $this->setData('payment', $payment);
66  return $this;
67  }
68 
74  protected function _toHtml()
75  {
76  return $this->getChildHtml('info');
77  }
78 }
__()
Definition: __.php:13
$payment
Definition: order.php:17
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Payment\Helper\Data $paymentData, array $data=[])
Definition: Payment.php:31
setData($key, $value=null)
Definition: DataObject.php:72
$paymentInfoBlock
Definition: shipment.php:14