From a850ff13d76c3932da3882e68146b20e1d1c5bf1 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 16 Jan 2024 10:27:10 +0100 Subject: [PATCH] IcingadbBackend: Remove isAvailable method and property As it is only used internally now, it is no more required --- .../Director/Integration/BackendInterface.php | 7 ------ .../Integration/Icingadb/IcingadbBackend.php | 22 +++---------------- .../MonitoringModule/Monitoring.php | 10 ++++----- 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/library/Director/Integration/BackendInterface.php b/library/Director/Integration/BackendInterface.php index e89e13922..7b2b88c18 100644 --- a/library/Director/Integration/BackendInterface.php +++ b/library/Director/Integration/BackendInterface.php @@ -6,13 +6,6 @@ interface BackendInterface { - /** - * Whether the backend is available - * - * @return bool - */ - public function isAvailable(): bool; - /** * Whether the backend has the given host * diff --git a/library/Director/Integration/Icingadb/IcingadbBackend.php b/library/Director/Integration/Icingadb/IcingadbBackend.php index 532c537f8..874cddde0 100644 --- a/library/Director/Integration/Icingadb/IcingadbBackend.php +++ b/library/Director/Integration/Icingadb/IcingadbBackend.php @@ -2,7 +2,6 @@ namespace Icinga\Module\Director\Integration\Icingadb; -use Icinga\Application\Modules\Module; use Icinga\Module\Director\Auth\Permission; use Icinga\Module\Director\Auth\Restriction; use Icinga\Module\Director\Integration\BackendInterface; @@ -19,22 +18,9 @@ class IcingadbBackend implements BackendInterface use Database; use Auth; - /** @var bool */ - protected $isAvailable; - - public function __construct() - { - $this->isAvailable = Module::exists('icingadb'); - } - - public function isAvailable(): bool - { - return $this->isAvailable; - } - public function hasHost(?string $hostName): bool { - if ($hostName === null || ! $this->isAvailable()) { + if ($hostName === null) { return false; } @@ -43,7 +29,7 @@ public function hasHost(?string $hostName): bool public function hasService(?string $hostName, ?string $serviceName): bool { - if ($hostName === null || $serviceName === null || ! $this->isAvailable()) { + if ($hostName === null || $serviceName === null) { return false; } @@ -52,7 +38,7 @@ public function hasService(?string $hostName, ?string $serviceName): bool public function getHostUrl(?string $hostName): ?Url { - if ($hostName === null || ! $this->isAvailable()) { + if ($hostName === null) { return null; } @@ -62,7 +48,6 @@ public function getHostUrl(?string $hostName): ?Url public function canModifyHost(?string $hostName): bool { if ($hostName === null - || ! $this->isAvailable() || ! $this->getAuth()->hasPermission(Permission::ICINGADB_HOSTS) ) { return false; @@ -77,7 +62,6 @@ public function canModifyService(?string $hostName, ?string $serviceName): bool { if ($hostName === null || $serviceName === null - || ! $this->isAvailable() || ! $this->getAuth()->hasPermission(Permission::ICINGADB_SERVICES) ) { return false; diff --git a/library/Director/Integration/MonitoringModule/Monitoring.php b/library/Director/Integration/MonitoringModule/Monitoring.php index cb574febe..5a2dfde84 100644 --- a/library/Director/Integration/MonitoringModule/Monitoring.php +++ b/library/Director/Integration/MonitoringModule/Monitoring.php @@ -28,11 +28,6 @@ public function __construct(Auth $auth) $this->initializeMonitoringBackend(); } - public function isAvailable(): bool - { - return $this->backend !== null; - } - public function getHostUrl(?string $hostName): ?Url { if ($hostName === null) { @@ -197,4 +192,9 @@ protected function initializeMonitoringBackend() } } } + + protected function isAvailable(): bool + { + return $this->backend !== null; + } }