From 86b5557c1e11e08e0dd32a357db2f9af751b777b Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 13 Jan 2026 10:08:38 +0100 Subject: [PATCH] Controllers: Add an `else` case to improve readability --- application/controllers/HostController.php | 12 ++++++------ application/controllers/IdoHostController.php | 4 ++-- application/controllers/IdoServiceController.php | 6 +++--- application/controllers/ServiceController.php | 14 +++++++------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index 886d34d..9daa468 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -26,12 +26,12 @@ class HostController extends CompatController if ($host !== null) { $this->redirectNow(Url::fromPath('icingadb/host')->setParams($this->params)); + } else { + $this->getTabs()->disableLegacyExtensions(); + + $this->view->host = $hostName; + $this->view->tabs = null; // compatController already creates tabs + $this->addContent(HtmlString::create($this->view->render('ido-host/show.phtml'))); } - - $this->getTabs()->disableLegacyExtensions(); - - $this->view->host = $hostName; - $this->view->tabs = null; // compatController already creates tabs - $this->addContent(HtmlString::create($this->view->render('ido-host/show.phtml'))); } } diff --git a/application/controllers/IdoHostController.php b/application/controllers/IdoHostController.php index b52d4fa..db12b5e 100644 --- a/application/controllers/IdoHostController.php +++ b/application/controllers/IdoHostController.php @@ -18,8 +18,8 @@ class IdoHostController extends Controller $this->applyRestriction('monitoring/filter/objects', $query); if ($query->fetchRow() !== false) { $this->redirectNow(Url::fromPath('monitoring/host/show')->setParams($this->params)); + } else { + $this->view->host = $hostName; } - - $this->view->host = $hostName; } } diff --git a/application/controllers/IdoServiceController.php b/application/controllers/IdoServiceController.php index 3f8c247..a869aa1 100644 --- a/application/controllers/IdoServiceController.php +++ b/application/controllers/IdoServiceController.php @@ -20,9 +20,9 @@ class IdoServiceController extends Controller $this->applyRestriction('monitoring/filter/objects', $query); if ($query->fetchRow() !== false) { $this->redirectNow(Url::fromPath('monitoring/service/show')->setParams($this->params)); + } else { + $this->view->host = $hostName; + $this->view->service = $serviceName; } - - $this->view->host = $hostName; - $this->view->service = $serviceName; } } diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index 241155b..2bc31e3 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -31,13 +31,13 @@ class ServiceController extends CompatController if ($service !== null) { $this->redirectNow(Url::fromPath('icingadb/service')->setParams($this->params)); + } else { + $this->getTabs()->disableLegacyExtensions(); + + $this->view->host = $hostName; + $this->view->service = $serviceName; + $this->view->tabs = null; // compatController already creates tabs + $this->addContent(HtmlString::create($this->view->render('ido-service/show.phtml'))); } - - $this->getTabs()->disableLegacyExtensions(); - - $this->view->host = $hostName; - $this->view->service = $serviceName; - $this->view->tabs = null; // compatController already creates tabs - $this->addContent(HtmlString::create($this->view->render('ido-service/show.phtml'))); } }