Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Creditmemo.php
Go to the documentation of this file.
1 <?php
7 
9 
17 class Creditmemo extends \Magento\Sales\Block\Order\Creditmemo\Items
18 {
22  protected $_template = 'Magento_Sales::order/creditmemo.phtml';
23 
27  protected $httpContext;
28 
32  protected $_paymentHelper;
33 
41  public function __construct(
42  \Magento\Framework\View\Element\Template\Context $context,
43  \Magento\Framework\Registry $registry,
44  \Magento\Framework\App\Http\Context $httpContext,
45  \Magento\Payment\Helper\Data $paymentHelper,
46  array $data = []
47  ) {
48  $this->_paymentHelper = $paymentHelper;
49  $this->httpContext = $httpContext;
50  parent::__construct($context, $registry, $data);
51  $this->_isScopePrivate = true;
52  }
53 
57  protected function _prepareLayout()
58  {
59  $this->pageConfig->getTitle()->set(__('Order # %1', $this->getOrder()->getRealOrderId()));
60  $infoBlock = $this->_paymentHelper->getInfoBlock($this->getOrder()->getPayment(), $this->getLayout());
61  $this->setChild('payment_info', $infoBlock);
62  }
63 
67  public function getPaymentInfoHtml()
68  {
69  return $this->getChildHtml('payment_info');
70  }
71 
77  public function getOrder()
78  {
79  return $this->_coreRegistry->registry('current_order');
80  }
81 
87  public function getBackUrl()
88  {
89  if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
90  return $this->getUrl('*/*/history');
91  }
92  return $this->getUrl('*/*/form');
93  }
94 
100  public function getBackTitle()
101  {
102  if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
103  return __('Back to My Orders');
104  }
105  return __('View Another Order');
106  }
107 
112  public function getInvoiceUrl($order)
113  {
114  return $this->getUrl('*/*/invoice', ['order_id' => $order->getId()]);
115  }
116 
121  public function getShipmentUrl($order)
122  {
123  return $this->getUrl('*/*/shipment', ['order_id' => $order->getId()]);
124  }
125 
130  public function getViewUrl($order)
131  {
132  return $this->getUrl('*/*/view', ['order_id' => $order->getId()]);
133  }
134 
140  {
141  return $this->getUrl('*/*/printCreditmemo', ['creditmemo_id' => $creditmemo->getId()]);
142  }
143 
149  {
150  return $this->getUrl('*/*/printCreditmemo', ['order_id' => $order->getId()]);
151  }
152 }
$order
Definition: order.php:55
__()
Definition: __.php:13
__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: Creditmemo.php:41