public function onRoutingResponse(RoutingResponse $routingResponse, HTTPRequestResponseContainer $httpRequestResponse) { $httpRequestResponse->setResponse($httpRequestResponse->getResponse()->withStatus($routingResponse->getStatusCode())); // Do a locally shared instance for request and response for proper injection. //@todo there should be a smarter way to do this. $dic = clone $this->dic; $dic->share($httpRequestResponse); $dic->share($httpRequestResponse->getRequest()); $dic->share($httpRequestResponse->getResponse()); $controller = $dic->make($routingResponse->getClass()); $controllerResponse = $dic->execute([$controller, $routingResponse->getMethod()], $routingResponse->getParameters()); $this->processControllerResponse($controllerResponse, $routingResponse->getClass(), $routingResponse->getMethod(), $httpRequestResponse); }
private function setPSR7ResponseFromString(string $string, HTTPRequestResponseContainer $httpContainer) { $body = $this->httpFactory->createStringStream((string) $string); $response = $httpContainer->getResponse()->withBody($body); $this->setPSR7Response($response, $httpContainer); }