/** * @param string $action * @return $this */ public function forward($action) { $this->request->initForward(); if (!empty($this->params)) { $this->request->setParams($this->params); } if (!empty($this->controller)) { $this->request->setControllerName($this->controller); // Module should only be reset if controller has been specified if (!empty($this->module)) { $this->request->setModuleName($this->module); } } $this->request->setActionName($action); $this->request->setDispatched(false); return $this; }
/** * @param RequestInterface $request * @param ResponseInterface $response * @return bool */ public function load(RequestInterface $request, ResponseInterface $response) { $newsId = (int) $request->getParam('id'); if (!$newsId) { $request->initForward(); $request->setActionName('noroute'); $request->setDispatched(false); return false; } $news = $this->newsFactory->create()->load($newsId); $this->registry->register('current_news', $news); return true; }
/** * @param RequestInterface $request * @param ResponseInterface $response * @return bool */ public function load(RequestInterface $request, ResponseInterface $response) { $orderId = (int) $request->getParam('order_id'); if (!$orderId) { $request->initForward(); $request->setActionName('noroute'); $request->setDispatched(false); return false; } $order = $this->orderFactory->create()->load($orderId); if ($this->orderAuthorization->canView($order)) { $this->registry->register('current_order', $order); return true; } $response->setRedirect($this->url->getUrl('*/*/history')); return false; }