mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 08:14:04 +02:00
ProvidedHook: do not fail on missing config
This commit is contained in:
parent
611c2aa1a6
commit
c6af8811a8
@ -14,6 +14,10 @@ class HostActions extends HostActionsHook
|
||||
public function getActionsForHost(Host $host)
|
||||
{
|
||||
$db = $this->db();
|
||||
if (! $db) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (IcingaHost::exists($host->host_name, $db)) {
|
||||
return array(
|
||||
'Modify' => Url::fromPath(
|
||||
@ -32,6 +36,11 @@ class HostActions extends HostActionsHook
|
||||
|
||||
protected function db()
|
||||
{
|
||||
return Db::fromResourceName(Config::module('director')->get('db', 'resource'));
|
||||
$resourceName = Config::module('director')->get('db', 'resource');
|
||||
if (! $resourceName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Db::fromResourceName($resourceName);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,10 @@ class ServiceActions extends ServiceActionsHook
|
||||
public function getActionsForService(Service $service)
|
||||
{
|
||||
$db = $this->db();
|
||||
if (! $db) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (IcingaHost::exists($service->host_name, $db)) {
|
||||
return array(
|
||||
'Inspect' => Url::fromPath(
|
||||
@ -36,6 +40,11 @@ class ServiceActions extends ServiceActionsHook
|
||||
|
||||
protected function db()
|
||||
{
|
||||
return Db::fromResourceName(Config::module('director')->get('db', 'resource'));
|
||||
$resourceName = Config::module('director')->get('db', 'resource');
|
||||
if (! $resourceName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Db::fromResourceName($resourceName);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user