Web\Response: add redirection function
The response now provides redirectAndExit(). One more step to clean up our action controller. Please not that this is still unused right now.
This commit is contained in:
parent
3772b9c16f
commit
3cfdf4c977
|
@ -3,7 +3,23 @@
|
|||
namespace Icinga\Web;
|
||||
|
||||
use Zend_Controller_Response_Http;
|
||||
use Icinga\Application\Icinga;
|
||||
|
||||
class Response extends Zend_Controller_Response_Http
|
||||
{
|
||||
public function redirectAndExit($url)
|
||||
{
|
||||
if (! $url instanceof Url) {
|
||||
$url = Url::fromPath($url);
|
||||
}
|
||||
$url->getParams()->setSeparator('&');
|
||||
|
||||
if (Icinga::app()->getFrontController()->getRequest()->isXmlHttpRequest()) {
|
||||
$this->setHeader('X-Icinga-Redirect', rawurlencode($url));
|
||||
} else {
|
||||
$this->setRedirect($url->getAbsoluteUrl());
|
||||
}
|
||||
$this->sendHeaders();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue