/** * Run application * * @return ResponseInterface */ public function launch() { $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName()); $this->_state->setAreaCode($areaCode); $this->_objectManager->configure($this->_configLoader->load($areaCode)); $this->_response = $this->_objectManager->get('Magento\\Framework\\App\\FrontControllerInterface')->dispatch($this->_request); // This event gives possibility to launch something before sending output (allow cookie setting) $eventParams = array('request' => $this->_request, 'response' => $this->_response); $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams); return $this->_response; }
/** * Run application * * @return ResponseInterface */ public function launch() { try { $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName()); $this->_state->setAreaCode($areaCode); $this->_objectManager->configure($this->_configLoader->load($areaCode)); $this->_response = $this->_objectManager->get('Magento\\Framework\\App\\FrontControllerInterface')->dispatch($this->_request); // This event gives possibility to launch something before sending output (allow cookie setting) $eventParams = array('request' => $this->_request, 'response' => $this->_response); $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams); } catch (\Exception $exception) { $message = $exception->getMessage() . "\n"; try { if ($this->_state->getMode() == State::MODE_DEVELOPER) { $message .= '<pre>'; $message .= $exception->getMessage() . "\n\n"; $message .= $exception->getTraceAsString(); $message .= '</pre>'; } else { $reportData = array($exception->getMessage(), $exception->getTraceAsString()); // retrieve server data if (isset($_SERVER)) { if (isset($_SERVER['REQUEST_URI'])) { $reportData['url'] = $_SERVER['REQUEST_URI']; } if (isset($_SERVER['SCRIPT_NAME'])) { $reportData['script_name'] = $_SERVER['SCRIPT_NAME']; } } require_once $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/report.php'; $processor = new \Magento\Framework\Error\Processor($this->_response); $processor->saveReport($reportData); $this->_response = $processor->processReport(); } } catch (\Exception $exception) { $message .= "Unknown error happened."; } $this->_response->setHttpResponseCode(500); $this->_response->setBody($message); } return $this->_response; }
/** * Run application * * @throws \InvalidArgumentException * @return ResponseInterface */ public function launch() { $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName()); $this->_state->setAreaCode($areaCode); $this->_objectManager->configure($this->_configLoader->load($areaCode)); /** @var \Magento\Framework\App\FrontControllerInterface $frontController */ $frontController = $this->_objectManager->get('Magento\\Framework\\App\\FrontControllerInterface'); $result = $frontController->dispatch($this->_request); // TODO: Temporary solution until all controllers return ResultInterface (MAGETWO-28359) if ($result instanceof ResultInterface) { $this->registry->register('use_page_cache_plugin', true, true); $result->renderResult($this->_response); } elseif ($result instanceof HttpInterface) { $this->_response = $result; } else { throw new \InvalidArgumentException('Invalid return type'); } // This event gives possibility to launch something before sending output (allow cookie setting) $eventParams = ['request' => $this->_request, 'response' => $this->_response]; $this->_eventManager->dispatch('controller_front_send_response_before', $eventParams); return $this->_response; }
public function testGetFrontName() { $uri = 'http://test.com/one/two'; $this->_model = $this->getModel($uri); $this->assertEquals('one', $this->_model->getFrontName()); }
public function testGetFrontName() { $this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock, 'http://test.com/one/two'); $this->assertEquals('one', $this->_model->getFrontName()); }