Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Info.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Payment\Block;
7 
15 {
22 
26  protected $_template = 'Magento_Payment::info/default.phtml';
27 
34  public function getInfo()
35  {
36  $info = $this->getData('info');
37  if (!$info instanceof \Magento\Payment\Model\InfoInterface) {
38  throw new \Magento\Framework\Exception\LocalizedException(
39  __('We cannot retrieve the payment info model object.')
40  );
41  }
42  return $info;
43  }
44 
50  public function getMethod()
51  {
52  return $this->getInfo()->getMethodInstance();
53  }
54 
59  public function toPdf()
60  {
61  $this->setTemplate('Magento_Payment::info/pdf/default.phtml');
62  return $this->toHtml();
63  }
64 
72  public function getChildPdfAsArray()
73  {
74  $result = [];
75  foreach ($this->getLayout()->getChildBlocks($this->getNameInLayout()) as $child) {
76  if (method_exists($child, 'toPdf') && is_callable([$child, 'toPdf'])) {
77  $result[] = $child->toPdf();
78  }
79  }
80  return $result;
81  }
82 
88  public function getSpecificInformation()
89  {
90  return $this->_prepareSpecificInformation()->getData();
91  }
92 
100  public function getValueAsArray($value, $escapeHtml = false)
101  {
102  if (empty($value)) {
103  return [];
104  }
105  if (!is_array($value)) {
106  $value = [$value];
107  }
108  if ($escapeHtml) {
109  foreach ($value as $_key => $_val) {
110  $value[$_key] = $this->escapeHtml($_val);
111  }
112  }
113  return $value;
114  }
115 
124  public function getIsSecureMode()
125  {
126  if ($this->hasIsSecureMode()) {
127  return (bool)(int)$this->_getData('is_secure_mode');
128  }
129 
130  $method = $this->getMethod();
131  if (!$method) {
132  return true;
133  }
134 
135  $store = $method->getStore();
136  if (!$store) {
137  return false;
138  }
139 
140  $methodStore = $this->_storeManager->getStore($store);
141  return $methodStore->getCode() != \Magento\Store\Model\Store::ADMIN_CODE;
142  }
143 
150  protected function _prepareSpecificInformation($transport = null)
151  {
152  if (null === $this->_paymentSpecificInformation) {
153  if (null === $transport) {
154  $transport = new \Magento\Framework\DataObject();
155  } elseif (is_array($transport)) {
156  $transport = new \Magento\Framework\DataObject($transport);
157  }
158  $this->_paymentSpecificInformation = $transport;
159  }
161  }
162 }
getData($key='', $index=null)
Definition: DataObject.php:119
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
__()
Definition: __.php:13
_prepareSpecificInformation($transport=null)
Definition: Info.php:150
$value
Definition: gender.phtml:16
$method
Definition: info.phtml:13
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52
getValueAsArray($value, $escapeHtml=false)
Definition: Info.php:100