From 3774eb688995bc8e0bc61add40e163055c175954 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 22 Jun 2014 15:36:41 +0200 Subject: [PATCH] ActionController: add isXhr() method Makes things easier as we use this a lot --- .../Icinga/Web/Controller/ActionController.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index ab7083314..c5f44029e 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -158,7 +158,7 @@ class ActionController extends Zend_Controller_Action protected function handlerBrowserWindows() { - if ($this->_request->isXmlHttpRequest()) { + if ($this->isXhr()) { $id = $this->_request->getHeader('X-Icinga-WindowId', null); if ($id === Window::UNDEFINED) { @@ -281,7 +281,7 @@ class ActionController extends Zend_Controller_Action protected function ignoreXhrBody() { - if ($this->getRequest()->isXmlHttpRequest()) { + if ($this->isXhr()) { $this->getResponse()->setHeader('X-Icinga-Container', 'ignore'); } } @@ -315,13 +315,18 @@ class ActionController extends Zend_Controller_Action protected function redirectToLogin($afterLogin = '/dashboard') { $url = Url::fromPath('/authentication/login'); - if ($this->getRequest()->isXmlHttpRequest()) { + if ($this->isXhr()) { $url->setParam('_render', 'layout'); } $url->setParam('redirect', $afterLogin); $this->redirectNow($url); } + public function isXhr() + { + return $this->getRequest()->isXmlHttpRequest(); + } + /** * Redirect to a specific url, updating the browsers URL field * @@ -330,7 +335,7 @@ class ActionController extends Zend_Controller_Action public function redirectNow($url) { $url = preg_replace('~&~', '&', $url); - if ($this->_request->isXmlHttpRequest()) { + if ($this->isXhr()) { $this->getResponse() ->setHeader('X-Icinga-Redirect', rawurlencode($url)) ->sendHeaders(); @@ -371,7 +376,7 @@ class ActionController extends Zend_Controller_Action exit; } - if ($req->isXmlHttpRequest()) { + if ($this->isXhr()) { $this->postDispatchXhr(); } }