lib: Allow to control reload CSS header in Response

Whenever the theme is switched, client side script code has to be instructed to reload CSS.

refs #10705
This commit is contained in:
Eric Lippmann 2015-11-27 15:44:40 +01:00
parent 5d4a628e2d
commit 8fb9d94f46
1 changed files with 36 additions and 0 deletions

View File

@ -7,6 +7,9 @@ use Zend_Controller_Response_Http;
use Icinga\Application\Icinga;
use Icinga\Web\Response\JsonResponse;
/**
* A HTTP response
*/
class Response extends Zend_Controller_Response_Http
{
/**
@ -23,6 +26,13 @@ class Response extends Zend_Controller_Response_Http
*/
protected $request;
/**
* Whether to instruct client side script code to reload CSS
*
* @var bool
*/
protected $reloadCss;
/**
* Whether to send the rerender layout header on XHR
*
@ -74,6 +84,29 @@ class Response extends Zend_Controller_Response_Http
return $this->request;
}
/**
* Get whether to instruct client side script code to reload CSS
*
* @return bool
*/
public function isReloadCss()
{
return $this->reloadCss;
}
/**
* Set whether to instruct client side script code to reload CSS
*
* @param bool $reloadCss
*
* @return $this
*/
public function setReloadCss($reloadCss)
{
$this->reloadCss = $reloadCss;
return $this;
}
/**
* Get whether to send the rerender layout header on XHR
*
@ -123,6 +156,9 @@ class Response extends Zend_Controller_Response_Http
if ($this->getRerenderLayout()) {
$this->setHeader('X-Icinga-Container', 'layout', true);
}
if ($this->isReloadCss()) {
$this->setHeader('X-Icinga-Reload-Css', 'now', true);
}
} else {
if ($redirectUrl !== null) {
$this->setRedirect($redirectUrl->getAbsoluteUrl());