parent
870b73ae09
commit
1c5a784022
|
@ -80,7 +80,7 @@ class ErrorController extends ActionController
|
|||
|
||||
if ($this->getRequest()->isApiRequest()) {
|
||||
// @TODO(el): Use ApiResponse class for unified response handling.
|
||||
$this->getRequest()->sendJson(array(
|
||||
$this->getResponse()->sendJson(array(
|
||||
'status' => 'error',
|
||||
'message' => $this->view->message
|
||||
));
|
||||
|
|
|
@ -1072,7 +1072,7 @@ class Form extends Zend_Form
|
|||
// notifications
|
||||
$messages = Notification::getInstance()->popMessages();
|
||||
// @TODO(el): Use ApiResponse class for unified response handling.
|
||||
$this->getRequest()->sendJson(array(
|
||||
$this->getResponse()->sendJson(array(
|
||||
'status' => 'success',
|
||||
'message' => array_pop($messages) // @TODO(el): Remove the type from the message
|
||||
));
|
||||
|
@ -1082,7 +1082,7 @@ class Form extends Zend_Form
|
|||
$this->getView()->layout()->redirectUrl = $this->getRedirectUrl()->getAbsoluteUrl();
|
||||
}
|
||||
} elseif ($this->getIsApiTarget()) {
|
||||
$this->getRequest()->sendJson(array(
|
||||
$this->getResponse()->sendJson(array(
|
||||
'status' => 'fail',
|
||||
'data' => array_merge($this->getMessages(), $this->getErrorMessages())
|
||||
));
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
namespace Icinga\Web;
|
||||
|
||||
use Zend_Controller_Action_HelperBroker;
|
||||
use Zend_Controller_Request_Http;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\User;
|
||||
|
@ -125,16 +124,4 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Web;
|
||||
|
||||
use Zend_Controller_Action_HelperBroker;
|
||||
use Zend_Controller_Response_Http;
|
||||
use Icinga\Application\Icinga;
|
||||
|
||||
|
@ -145,4 +146,16 @@ class Response extends Zend_Controller_Response_Http
|
|||
$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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue