public function dispatch() { $route = $this->router->findRoute($this->request); $this->request->setRoute($route); try { $responseDTO = $this->handleRequest($route); $viewModel = $this->translateResponseData($responseDTO); $this->response->setViewModel($viewModel); $this->response->send(); } catch (RequestHandlingException $exception) { // handle exception } catch (ResponseHandlingException $exception) { // handle exception } }
/** * */ public function run() { $dispatcher = new DispatchRequest(Request::createRequestFromGlobals(), new Router(), ResponseFactory::create($this->config->get('freyr_envelope.response.class'))); $dispatcher->dispatch(); }