mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 16:24:05 +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)
|
public function getActionsForHost(Host $host)
|
||||||
{
|
{
|
||||||
$db = $this->db();
|
$db = $this->db();
|
||||||
|
if (! $db) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
if (IcingaHost::exists($host->host_name, $db)) {
|
if (IcingaHost::exists($host->host_name, $db)) {
|
||||||
return array(
|
return array(
|
||||||
'Modify' => Url::fromPath(
|
'Modify' => Url::fromPath(
|
||||||
@ -32,6 +36,11 @@ class HostActions extends HostActionsHook
|
|||||||
|
|
||||||
protected function db()
|
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)
|
public function getActionsForService(Service $service)
|
||||||
{
|
{
|
||||||
$db = $this->db();
|
$db = $this->db();
|
||||||
|
if (! $db) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
if (IcingaHost::exists($service->host_name, $db)) {
|
if (IcingaHost::exists($service->host_name, $db)) {
|
||||||
return array(
|
return array(
|
||||||
'Inspect' => Url::fromPath(
|
'Inspect' => Url::fromPath(
|
||||||
@ -36,6 +40,11 @@ class ServiceActions extends ServiceActionsHook
|
|||||||
|
|
||||||
protected function db()
|
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