lib/Response: Allow to control the auto-refresh interval

This commit is contained in:
Eric Lippmann 2016-01-27 09:14:11 +01:00
parent c963ee23ff
commit 78c1e17c20
1 changed files with 33 additions and 0 deletions

View File

@ -12,6 +12,13 @@ use Icinga\Web\Response\JsonResponse;
*/
class Response extends Zend_Controller_Response_Http
{
/**
* Auto-refresh interval
*
* @var int
*/
protected $autoRefreshInterval;
/**
* Set of cookies which are to be sent to the client
*
@ -47,6 +54,29 @@ class Response extends Zend_Controller_Response_Http
*/
protected $rerenderLayout = false;
/**
* Get the auto-refresh interval
*
* @return int
*/
public function getAutoRefreshInterval()
{
return $this->autoRefreshInterval;
}
/**
* Set the auto-refresh interval
*
* @param int $autoRefreshInterval
*
* @return $this
*/
public function setAutoRefreshInterval($autoRefreshInterval)
{
$this->autoRefreshInterval = $autoRefreshInterval;
return $this;
}
/**
* Get the set of cookies which are to be sent to the client
*
@ -204,6 +234,9 @@ class Response extends Zend_Controller_Response_Http
if ($this->isReloadCss()) {
$this->setHeader('X-Icinga-Reload-Css', 'now', true);
}
if (($autoRefreshInterval = $this->getAutoRefreshInterval()) !== null) {
$this->setHeader('X-Icinga-Refresh', $autoRefreshInterval, true);
}
} else {
if ($redirectUrl !== null) {
$this->setRedirect($redirectUrl->getAbsoluteUrl());