![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-sales/Controller/AbstractController/ |
<?php /** * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Sales\Controller\AbstractController; use Magento\Framework\App\Action\Context; use Magento\Framework\View\Result\PageFactory; abstract class PrintInvoice extends \Magento\Framework\App\Action\Action { /** * @var OrderViewAuthorizationInterface */ protected $orderAuthorization; /** * @var \Magento\Framework\Registry */ protected $_coreRegistry; /** * @var PageFactory */ protected $resultPageFactory; /** * @param Context $context * @param OrderViewAuthorizationInterface $orderAuthorization * @param \Magento\Framework\Registry $registry * @param PageFactory $resultPageFactory */ public function __construct( Context $context, OrderViewAuthorizationInterface $orderAuthorization, \Magento\Framework\Registry $registry, PageFactory $resultPageFactory ) { $this->orderAuthorization = $orderAuthorization; $this->_coreRegistry = $registry; $this->resultPageFactory = $resultPageFactory; parent::__construct($context); } /** * Print Invoice Action * * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page */ public function execute() { $invoiceId = (int)$this->getRequest()->getParam('invoice_id'); if ($invoiceId) { $invoice = $this->_objectManager->create( \Magento\Sales\Api\InvoiceRepositoryInterface::class )->get($invoiceId); $order = $invoice->getOrder(); } else { $orderId = (int)$this->getRequest()->getParam('order_id'); $order = $this->_objectManager->create(\Magento\Sales\Model\Order::class)->load($orderId); } if ($this->orderAuthorization->canView($order)) { $this->_coreRegistry->register('current_order', $order); if (isset($invoice)) { $this->_coreRegistry->register('current_invoice', $invoice); } /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->addHandle('print'); return $resultPage; } else { /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); if ($this->_objectManager->get(\Magento\Customer\Model\Session::class)->isLoggedIn()) { $resultRedirect->setPath('*/*/history'); } else { $resultRedirect->setPath('sales/guest/form'); } return $resultRedirect; } } }