Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
PrintInvoice Class Reference
Inheritance diagram for PrintInvoice:
PrintInvoice Action AbstractAction ActionInterface

Public Member Functions

 __construct (Context $context, OrderViewAuthorization $orderAuthorization, \Magento\Framework\Registry $registry, PageFactory $resultPageFactory, OrderLoader $orderLoader)
 
 execute ()
 
- Public Member Functions inherited from PrintInvoice
 __construct (Context $context, OrderViewAuthorizationInterface $orderAuthorization, \Magento\Framework\Registry $registry, PageFactory $resultPageFactory)
 
- Public Member Functions inherited from Action
 __construct (Context $context)
 
 dispatch (RequestInterface $request)
 
 getActionFlag ()
 
- Public Member Functions inherited from AbstractAction
 __construct (Context $context)
 
 dispatch (RequestInterface $request)
 
 getRequest ()
 
 getResponse ()
 

Protected Attributes

 $orderLoader
 
- Protected Attributes inherited from PrintInvoice
 $orderAuthorization
 
 $_coreRegistry
 
 $resultPageFactory
 
- Protected Attributes inherited from Action
 $_objectManager
 
 $_sessionNamespace
 
 $_eventManager
 
 $_actionFlag
 
 $_redirect
 
 $_view
 
 $_url
 
 $messageManager
 
- Protected Attributes inherited from AbstractAction
 $_request
 
 $_response
 
 $resultRedirectFactory
 
 $resultFactory
 

Additional Inherited Members

- Data Fields inherited from ActionInterface
const FLAG_NO_DISPATCH = 'no-dispatch'
 
const FLAG_NO_POST_DISPATCH = 'no-postDispatch'
 
const FLAG_NO_DISPATCH_BLOCK_EVENT = 'no-beforeGenerateLayoutBlocksDispatch'
 
const PARAM_NAME_BASE64_URL = 'r64'
 
const PARAM_NAME_URL_ENCODED = 'uenc'
 
- Protected Member Functions inherited from Action
 _forward ($action, $controller=null, $module=null, array $params=null)
 
 _redirect ($path, $arguments=[])
 

Detailed Description

Definition at line 12 of file PrintInvoice.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Context  $context,
OrderViewAuthorization  $orderAuthorization,
\Magento\Framework\Registry  $registry,
PageFactory  $resultPageFactory,
OrderLoader  $orderLoader 
)
Parameters
Context$context
OrderViewAuthorization$orderAuthorization
\Magento\Framework\Registry$registry
PageFactory$resultPageFactory
OrderLoader$orderLoader

Definition at line 26 of file PrintInvoice.php.

Member Function Documentation

◆ execute()

execute ( )

{Execute action based on request and return resultNote: Request will be added as operation argument in future

Returns
\Magento\Framework\Controller\ResultInterface|ResponseInterface
Exceptions
}

Print Invoice Action

Returns
\Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page

Implements ActionInterface.

Definition at line 45 of file PrintInvoice.php.

46  {
47  $result = $this->orderLoader->load($this->_request);
48  if ($result instanceof \Magento\Framework\Controller\ResultInterface) {
49  return $result;
50  }
51 
52  $invoiceId = (int)$this->getRequest()->getParam('invoice_id');
53  if ($invoiceId) {
54  $invoice = $this->_objectManager->create(
55  \Magento\Sales\Api\InvoiceRepositoryInterface::class
56  )->get($invoiceId);
57  $order = $invoice->getOrder();
58  } else {
59  $order = $this->_coreRegistry->registry('current_order');
60  }
61 
62  if ($this->orderAuthorization->canView($order)) {
63  if (isset($invoice)) {
64  $this->_coreRegistry->register('current_invoice', $invoice);
65  }
66  return $this->resultPageFactory->create()->addHandle('print');
67  } else {
68  return $this->resultRedirectFactory->create()->setPath('sales/guest/form');
69  }
70  }
$order
Definition: order.php:55
$invoice

Field Documentation

◆ $orderLoader

$orderLoader
protected

Definition at line 17 of file PrintInvoice.php.


The documentation for this class was generated from the following file: