Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Invoice.php
Go to the documentation of this file.
1 <?php
7 
9 
17 {
23  protected $_coreRegistry = null;
24 
28  protected $_paymentHelper;
29 
33  protected $addressRenderer;
34 
42  public function __construct(
43  \Magento\Framework\View\Element\Template\Context $context,
44  \Magento\Framework\Registry $registry,
45  \Magento\Payment\Helper\Data $paymentHelper,
47  array $data = []
48  ) {
49  $this->addressRenderer = $addressRenderer;
50  $this->_paymentHelper = $paymentHelper;
51  $this->_coreRegistry = $registry;
52  parent::__construct($context, $data);
53  }
54 
58  protected function _prepareLayout()
59  {
60  $this->pageConfig->getTitle()->set(__('Order # %1', $this->getOrder()->getRealOrderId()));
61  $infoBlock = $this->_paymentHelper->getInfoBlock($this->getOrder()->getPayment(), $this->getLayout());
62  $this->setChild('payment_info', $infoBlock);
63  }
64 
68  public function getBackUrl()
69  {
70  return $this->getUrl('*/*/history');
71  }
72 
76  public function getPrintUrl()
77  {
78  return $this->getUrl('*/*/print');
79  }
80 
84  public function getPaymentInfoHtml()
85  {
86  return $this->getChildHtml('payment_info');
87  }
88 
92  public function getOrder()
93  {
94  return $this->_coreRegistry->registry('current_order');
95  }
96 
100  public function getInvoice()
101  {
102  return $this->_coreRegistry->registry('current_invoice');
103  }
104 
109  protected function _prepareItem(AbstractBlock $renderer)
110  {
111  $renderer->setPrintStatus(true);
112  return parent::_prepareItem($renderer);
113  }
114 
122  {
123  $html = '';
124  $totals = $this->getChildBlock('invoice_totals');
125  if ($totals) {
126  $totals->setInvoice($invoice);
127  $html = $totals->toHtml();
128  }
129  return $html;
130  }
131 
139  public function formatAddress(\Magento\Sales\Model\Order\Address $address, $format)
140  {
141  return $this->addressRenderer->format($address, $format);
142  }
143 }
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Payment\Helper\Data $paymentHelper, \Magento\Sales\Model\Order\Address\Renderer $addressRenderer, array $data=[])
Definition: Invoice.php:42
__()
Definition: __.php:13
$address
Definition: customer.php:38
$format
Definition: list.phtml:12
$totals
Definition: totalbar.phtml:10
$invoice
formatAddress(\Magento\Sales\Model\Order\Address $address, $format)
Definition: Invoice.php:139
_prepareItem(AbstractBlock $renderer)
Definition: Invoice.php:109