Skip to content
Snippets Groups Projects
Commit 4343fe35 authored by Chris Hallberg's avatar Chris Hallberg Committed by Demian Katz
Browse files

Added ability to set JSON response status code.

parent 74b93edb
No related merge requests found
...@@ -57,16 +57,18 @@ class HierarchyController extends AbstractBase ...@@ -57,16 +57,18 @@ class HierarchyController extends AbstractBase
/** /**
* Output JSON * Output JSON
* *
* @param string $json A JSON string * @param string $json A JSON string
* @param int $status Response status code
* *
* @return \Zend\Http\Response * @return \Zend\Http\Response
*/ */
protected function outputJSON($json) protected function outputJSON($json, $status = 200)
{ {
$response = $this->getResponse(); $response = $this->getResponse();
$headers = $response->getHeaders(); $headers = $response->getHeaders();
$headers->addHeaderLine('Content-type', 'application/json'); $headers->addHeaderLine('Content-type', 'application/json');
$response->setContent($json); $response->setContent($json);
$response->setStatusCode($status);
return $response; return $response;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment