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 
16 class Invoice extends \Magento\Sales\Block\Order\Invoice\Items
17 {
21  protected $_template = 'Magento_Sales::order/invoice.phtml';
22 
26  protected $httpContext;
27 
31  protected $_paymentHelper;
32 
40  public function __construct(
41  \Magento\Framework\View\Element\Template\Context $context,
42  \Magento\Framework\Registry $registry,
43  \Magento\Framework\App\Http\Context $httpContext,
44  \Magento\Payment\Helper\Data $paymentHelper,
45  array $data = []
46  ) {
47  $this->_paymentHelper = $paymentHelper;
48  $this->httpContext = $httpContext;
49  parent::__construct($context, $registry, $data);
50  $this->_isScopePrivate = true;
51  }
52 
56  protected function _prepareLayout()
57  {
58  $this->pageConfig->getTitle()->set(__('Order # %1', $this->getOrder()->getRealOrderId()));
59  $infoBlock = $this->_paymentHelper->getInfoBlock($this->getOrder()->getPayment(), $this->getLayout());
60  $this->setChild('payment_info', $infoBlock);
61  }
62 
66  public function getPaymentInfoHtml()
67  {
68  return $this->getChildHtml('payment_info');
69  }
70 
76  public function getOrder()
77  {
78  return $this->_coreRegistry->registry('current_order');
79  }
80 
86  public function getBackUrl()
87  {
88  if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
89  return $this->getUrl('*/*/history');
90  }
91  return $this->getUrl('*/*/form');
92  }
93 
99  public function getBackTitle()
100  {
101  if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
102  return __('Back to My Orders');
103  }
104  return __('View Another Order');
105  }
106 
111  public function getViewUrl($order)
112  {
113  return $this->getUrl('*/*/view', ['order_id' => $order->getId()]);
114  }
115 
120  public function getShipmentUrl($order)
121  {
122  return $this->getUrl('*/*/shipment', ['order_id' => $order->getId()]);
123  }
124 
129  public function getCreditmemoUrl($order)
130  {
131  return $this->getUrl('*/*/creditmemo', ['order_id' => $order->getId()]);
132  }
133 
138  public function getPrintInvoiceUrl($invoice)
139  {
140  return $this->getUrl('*/*/printInvoice', ['invoice_id' => $invoice->getId()]);
141  }
142 
148  {
149  return $this->getUrl('*/*/printInvoice', ['order_id' => $order->getId()]);
150  }
151 }
$order
Definition: order.php:55
__()
Definition: __.php:13
$invoice
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Http\Context $httpContext, \Magento\Payment\Helper\Data $paymentHelper, array $data=[])
Definition: Invoice.php:40