View.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Sales\Controller\Adminhtml\Order\Invoice;
  8. use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
  9. use Magento\Framework\View\Result\PageFactory;
  10. use Magento\Backend\App\Action\Context;
  11. use Magento\Framework\Registry;
  12. class View extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View implements HttpGetActionInterface
  13. {
  14. /**
  15. * @var PageFactory
  16. */
  17. protected $resultPageFactory;
  18. /**
  19. * @param Context $context
  20. * @param Registry $registry
  21. * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
  22. * @param PageFactory $resultPageFactory
  23. */
  24. public function __construct(
  25. Context $context,
  26. Registry $registry,
  27. \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
  28. PageFactory $resultPageFactory
  29. ) {
  30. $this->resultPageFactory = $resultPageFactory;
  31. parent::__construct($context, $registry, $resultForwardFactory);
  32. }
  33. /**
  34. * Invoice information page
  35. *
  36. * @return \Magento\Framework\Controller\ResultInterface
  37. */
  38. public function execute()
  39. {
  40. $invoice = $this->getInvoice();
  41. if (!$invoice) {
  42. /** @var \Magento\Framework\Controller\Result\Forward $resultForward */
  43. $resultForward = $this->resultForwardFactory->create();
  44. return $resultForward->forward('noroute');
  45. }
  46. /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
  47. $resultPage = $this->resultPageFactory->create();
  48. $resultPage->setActiveMenu('Magento_Sales::sales_order');
  49. $resultPage->getConfig()->getTitle()->prepend(__('Invoices'));
  50. $resultPage->getConfig()->getTitle()->prepend(sprintf("#%s", $invoice->getIncrementId()));
  51. $resultPage->getLayout()->getBlock(
  52. 'sales_invoice_view'
  53. )->updateBackButtonUrl(
  54. $this->getRequest()->getParam('come_from')
  55. );
  56. return $resultPage;
  57. }
  58. }