lib: Introduce Response::setRerenderLayout()
Instead of handling response headers based on flags in our controllers, this should happen in the request for usage w/o controllers. refs #9660
This commit is contained in:
parent
91720810cc
commit
aaae7e03b4
|
@ -15,6 +15,13 @@ class Response extends Zend_Controller_Response_Http
|
|||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Whether to send the rerender layout header on XHR
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $rerenderLayout = false;
|
||||
|
||||
/**
|
||||
* Get the request
|
||||
*
|
||||
|
@ -28,6 +35,39 @@ class Response extends Zend_Controller_Response_Http
|
|||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether to send the rerender layout header on XHR
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getRerenderLayout()
|
||||
{
|
||||
return $this->rerenderLayout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether to send the rerender layout header on XHR
|
||||
*
|
||||
* @param bool $rerenderLayout
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRerenderLayout($rerenderLayout = true)
|
||||
{
|
||||
$this->rerenderLayout = (bool) $rerenderLayout;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the request before sending
|
||||
*/
|
||||
protected function prepare()
|
||||
{
|
||||
if ($this->getRequest()->isXmlHttpRequest() && $this->getRerenderLayout()) {
|
||||
$this->setHeader('X-Icinga-Rerender-Layout', 'yes');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the given URL and exit immediately
|
||||
*
|
||||
|
@ -54,4 +94,13 @@ class Response extends Zend_Controller_Response_Http
|
|||
$this->sendHeaders();
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function sendHeaders()
|
||||
{
|
||||
$this->prepare();
|
||||
return parent::sendHeaders();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue