Skip to content

Commit

Permalink
IcingadbBackend: Remove isAvailable method and property
Browse files Browse the repository at this point in the history
As it is only used internally now, it is no more required
  • Loading branch information
sukhwinder33445 committed Jan 16, 2024
1 parent 2461724 commit a850ff1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 31 deletions.
7 changes: 0 additions & 7 deletions library/Director/Integration/BackendInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@

interface BackendInterface
{
/**
* Whether the backend is available
*
* @return bool
*/
public function isAvailable(): bool;

/**
* Whether the backend has the given host
*
Expand Down
22 changes: 3 additions & 19 deletions library/Director/Integration/Icingadb/IcingadbBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions library/Director/Integration/MonitoringModule/Monitoring.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -197,4 +192,9 @@ protected function initializeMonitoringBackend()
}
}
}

protected function isAvailable(): bool
{
return $this->backend !== null;
}
}

0 comments on commit a850ff1

Please sign in to comment.