Hey thought I'd let you know I had trouble with the invoke method because I wanted to see the status code and headers, and that method only returns the content inside the response. No biggie I just subclassed and reimplemented that method to return an array of those things, also renamed a few variables:
// Dispatch request.
$response = $this->router->dispatch($request);
if (method_exists($response, 'getOriginalContent'))
{
$responseBody = $response->getOriginalContent();
}
else
{
$responseBody = $response->getContent();
}
// Decode json content.
if ($response->headers->get('content-type') == 'application/json')
{
if (function_exists('json_decode') and is_string($responseBody))
{
$responseBody = json_decode($responseBody, true);
}
}
// Restore the request input and route back to the original state.
$this->request->replace($originalInput);
$result['body'] = $responseBody;
$result['status'] = $response->getStatusCode();
$result['header'] = $response->headers->all();
return $result;
Hey thought I'd let you know I had trouble with the invoke method because I wanted to see the status code and headers, and that method only returns the content inside the response. No biggie I just subclassed and reimplemented that method to return an array of those things, also renamed a few variables: