QuickForm: add API helpers
This commit is contained in:
parent
4803e11b49
commit
16c4bd4da8
|
@ -68,6 +68,8 @@ abstract class QuickForm extends Zend_Form
|
|||
|
||||
protected $hintCount = 0;
|
||||
|
||||
protected $isApiRequest = false;
|
||||
|
||||
public function __construct($options = null)
|
||||
{
|
||||
parent::__construct($this->handleOptions($options));
|
||||
|
@ -153,6 +155,17 @@ abstract class QuickForm extends Zend_Form
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setApiRequest($isApiRequest = true)
|
||||
{
|
||||
$this->isApiRequest = $isApiRequest;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isApiRequest()
|
||||
{
|
||||
return $this->isApiRequest;
|
||||
}
|
||||
|
||||
protected function loadForm($name, Module $module = null)
|
||||
{
|
||||
if ($module === null) {
|
||||
|
@ -363,6 +376,11 @@ abstract class QuickForm extends Zend_Form
|
|||
|
||||
public function redirectOnSuccess($message = null)
|
||||
{
|
||||
if ($this->isApiRequest()) {
|
||||
Icinga::app()->getFrontController()->getResponse()->setMessage($message);
|
||||
return; // TODO: Shutdown?
|
||||
}
|
||||
|
||||
$url = $this->getSuccessUrl();
|
||||
$this->notifySuccess($this->getSuccessMessage($message));
|
||||
$this->redirectAndExit($url);
|
||||
|
@ -392,6 +410,12 @@ abstract class QuickForm extends Zend_Form
|
|||
Icinga::app()->getFrontController()->getResponse()->redirectAndExit($url);
|
||||
}
|
||||
|
||||
protected function setHttpResponseCode($code)
|
||||
{
|
||||
Icinga::app()->getFrontController()->getResponse()->setHttpResponseCode($code);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function onRequest()
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue