From c56cbf25d6c5ebc80200e3d80eb9701ee992d634 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 13 Jun 2022 09:31:35 +0200 Subject: [PATCH] Replace `count(getEntries())` with `countEntries()` --- application/controllers/DashboardsController.php | 4 ++-- library/Icinga/Web/Dashboard/Common/DashboardManager.php | 6 +++--- library/Icinga/Web/Dashboard/Settings.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/application/controllers/DashboardsController.php b/application/controllers/DashboardsController.php index eed71569f..3db49a9ce 100644 --- a/application/controllers/DashboardsController.php +++ b/application/controllers/DashboardsController.php @@ -505,7 +505,7 @@ class DashboardsController extends CompatController $activeHome = $this->dashboard->getActiveHome(); // We can't grant access the user to the dashboard manager if there aren't any dashboards to manage - if (! $activeHome || (! $activeHome->hasEntries() && count($this->dashboard->getEntries()) === 1)) { + if (! $activeHome || (! $activeHome->hasEntries() && $this->dashboard->countEntries() === 1)) { $this->redirectNow(Dashboard::BASE_ROUTE); } @@ -538,7 +538,7 @@ class DashboardsController extends CompatController && ( ! $activeHome->isDefaultHome() || $activeHome->hasEntries() - || count($this->dashboard->getEntries()) > 1 + || $this->dashboard->countEntries() > 1 ) ) { $params = []; diff --git a/library/Icinga/Web/Dashboard/Common/DashboardManager.php b/library/Icinga/Web/Dashboard/Common/DashboardManager.php index b5a44620f..8f7eb563f 100644 --- a/library/Icinga/Web/Dashboard/Common/DashboardManager.php +++ b/library/Icinga/Web/Dashboard/Common/DashboardManager.php @@ -157,13 +157,13 @@ trait DashboardManager $homes = is_array($entryOrEntries) ? $entryOrEntries : [$entryOrEntries]; // Highest priority is 0, so count($entries) are always lowest prio + 1 - $priority = count($this->getEntries()); + $priority = $this->countEntries(); /** @var DashboardHome $home */ foreach ($homes as $home) { if (! $this->hasEntry($home->getName())) { $conn->insert(DashboardHome::TABLE, [ - 'user_id' => self::getUser()->getAdditional('id'), + 'user_id' => $this::getUser()->getAdditional('id'), 'name' => $home->getName(), 'label' => $home->getTitle(), 'priority' => $home->isDefaultHome() ? 0 : $priority++, @@ -184,7 +184,7 @@ trait DashboardManager } /** - * Get and|or init the default dashboard home + * Initialize and get the default dashboard home * * @return DashboardHome */ diff --git a/library/Icinga/Web/Dashboard/Settings.php b/library/Icinga/Web/Dashboard/Settings.php index 9f627e0aa..16b409175 100644 --- a/library/Icinga/Web/Dashboard/Settings.php +++ b/library/Icinga/Web/Dashboard/Settings.php @@ -24,7 +24,7 @@ class Settings extends BaseHtmlElement protected function assemble() { $activeHome = $this->dashboard->getActiveHome(); - if (count($this->dashboard->getEntries()) === 1 && $activeHome->isDefaultHome()) { + if ($this->dashboard->countEntries() === 1 && $activeHome->isDefaultHome()) { $this->setAttribute('data-icinga-home', DashboardHome::DEFAULT_HOME); $this->addFrom((new DashboardHomeList($activeHome))->setHeaderDisabled()); } else {