From e07cdd21acab6ef2211d2636c3a2bcbd5a4bffca Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 20 Aug 2015 13:02:41 +0200 Subject: [PATCH] lib: Add Request::sendJson() refs #9606 --- library/Icinga/Web/Request.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Request.php b/library/Icinga/Web/Request.php index b4d7e92d4..3f9a6a506 100644 --- a/library/Icinga/Web/Request.php +++ b/library/Icinga/Web/Request.php @@ -3,8 +3,9 @@ namespace Icinga\Web; -use Icinga\Application\Icinga; +use Zend_Controller_Action_HelperBroker; use Zend_Controller_Request_Http; +use Icinga\Application\Icinga; use Icinga\User; /** @@ -124,4 +125,16 @@ class Request extends Zend_Controller_Request_Http $cookie = new Cookie($this); return $cookie->isSupported(); } + + /** + * 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); + } }