mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
parent
870b73ae09
commit
1c5a784022
@ -80,7 +80,7 @@ class ErrorController extends ActionController
|
|||||||
|
|
||||||
if ($this->getRequest()->isApiRequest()) {
|
if ($this->getRequest()->isApiRequest()) {
|
||||||
// @TODO(el): Use ApiResponse class for unified response handling.
|
// @TODO(el): Use ApiResponse class for unified response handling.
|
||||||
$this->getRequest()->sendJson(array(
|
$this->getResponse()->sendJson(array(
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => $this->view->message
|
'message' => $this->view->message
|
||||||
));
|
));
|
||||||
|
@ -1072,7 +1072,7 @@ class Form extends Zend_Form
|
|||||||
// notifications
|
// notifications
|
||||||
$messages = Notification::getInstance()->popMessages();
|
$messages = Notification::getInstance()->popMessages();
|
||||||
// @TODO(el): Use ApiResponse class for unified response handling.
|
// @TODO(el): Use ApiResponse class for unified response handling.
|
||||||
$this->getRequest()->sendJson(array(
|
$this->getResponse()->sendJson(array(
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => array_pop($messages) // @TODO(el): Remove the type from the message
|
'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();
|
$this->getView()->layout()->redirectUrl = $this->getRedirectUrl()->getAbsoluteUrl();
|
||||||
}
|
}
|
||||||
} elseif ($this->getIsApiTarget()) {
|
} elseif ($this->getIsApiTarget()) {
|
||||||
$this->getRequest()->sendJson(array(
|
$this->getResponse()->sendJson(array(
|
||||||
'status' => 'fail',
|
'status' => 'fail',
|
||||||
'data' => array_merge($this->getMessages(), $this->getErrorMessages())
|
'data' => array_merge($this->getMessages(), $this->getErrorMessages())
|
||||||
));
|
));
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
namespace Icinga\Web;
|
namespace Icinga\Web;
|
||||||
|
|
||||||
use Zend_Controller_Action_HelperBroker;
|
|
||||||
use Zend_Controller_Request_Http;
|
use Zend_Controller_Request_Http;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
@ -125,16 +124,4 @@ class Request extends Zend_Controller_Request_Http
|
|||||||
$cookie = new Cookie($this);
|
$cookie = new Cookie($this);
|
||||||
return $cookie->isSupported();
|
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;
|
namespace Icinga\Web;
|
||||||
|
|
||||||
|
use Zend_Controller_Action_HelperBroker;
|
||||||
use Zend_Controller_Response_Http;
|
use Zend_Controller_Response_Http;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
|
|
||||||
@ -145,4 +146,16 @@ class Response extends Zend_Controller_Response_Http
|
|||||||
$this->prepare();
|
$this->prepare();
|
||||||
return parent::sendHeaders();
|
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…
x
Reference in New Issue
Block a user