Skip to content

Commit

Permalink
lib: Replace Repsonse::sendJson() w/ Response::json()
Browse files Browse the repository at this point in the history
refs #9606
  • Loading branch information
lippserd committed Sep 7, 2015
1 parent a9cb8bf commit 25abc16
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions library/Icinga/Web/Response.php
Expand Up @@ -3,9 +3,9 @@

namespace Icinga\Web;

use Zend_Controller_Action_HelperBroker;
use Zend_Controller_Response_Http;
use Icinga\Application\Icinga;
use Icinga\Web\Response\JsonResponse;

class Response extends Zend_Controller_Response_Http
{
Expand Down Expand Up @@ -97,6 +97,16 @@ public function setRerenderLayout($rerenderLayout = true)
return $this;
}

/**
* Entry point for HTTP responses in JSON format
*
* @return JsonResponse
*/
public static function json()
{
return new JsonResponse();
}

/**
* Prepare the request before sending
*/
Expand Down Expand Up @@ -146,16 +156,4 @@ public function sendHeaders()
$this->prepare();
return parent::sendHeaders();
}

/**
* Immediately respond w/ the given data encoded in JSON
*
* @param array $data
*/
public function sendJson(array $data)
{
$helper = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
/** @var \Zend_Controller_Action_Helper_Json $helper */
$helper->sendJson($data);
}
}

0 comments on commit 25abc16

Please sign in to comment.