orderFactory = $orderFactory; $this->orderAuthorization = $orderAuthorization; $this->registry = $registry; $this->url = $url; $this->resultForwardFactory = $resultForwardFactory; $this->redirectFactory = $redirectFactory; } /** * @param RequestInterface $request * @return bool|\Magento\Framework\Controller\Result\Forward|\Magento\Framework\Controller\Result\Redirect */ public function load(RequestInterface $request) { $orderId = (int)$request->getParam('order_id'); if (!$orderId) { /** @var \Magento\Framework\Controller\Result\Forward $resultForward */ $resultForward = $this->resultForwardFactory->create(); return $resultForward->forward('noroute'); } $order = $this->orderFactory->create()->load($orderId); if ($this->orderAuthorization->canView($order)) { $this->registry->register('current_order', $order); return true; } /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->redirectFactory->create(); return $resultRedirect->setUrl($this->url->getUrl('*/*/history')); } }