registry = $registry; parent::__construct($context); $this->resultForwardFactory = $resultForwardFactory; } /** * Invoice information page * * @return \Magento\Backend\Model\View\Result\Forward */ public function execute() { $resultForward = $this->resultForwardFactory->create(); if ($this->getRequest()->getParam('invoice_id')) { $resultForward->setController('order_invoice') ->setParams(['come_from' => 'invoice']) ->forward('view'); } else { $resultForward->forward('noroute'); } return $resultForward; } /** * @return \Magento\Sales\Model\Order\Invoice|bool */ protected function getInvoice() { try { $invoice = $this->getInvoiceRepository() ->get($this->getRequest()->getParam('invoice_id')); $this->registry->register('current_invoice', $invoice); } catch (\Exception $e) { $this->messageManager->addErrorMessage(__('Invoice capturing error')); return false; } return $invoice; } /** * @return InvoiceRepository * * @deprecated 100.1.0 */ private function getInvoiceRepository() { if ($this->invoiceRepository === null) { $this->invoiceRepository = ObjectManager::getInstance() ->get(InvoiceRepositoryInterface::class); } return $this->invoiceRepository; } }