summaryrefslogtreecommitdiffstats
path: root/library/Map/ProvidedHook/Monitoring/HostActions.php
blob: d64f743c3e8baa5aa77add38e959a6fbe14a55d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

namespace Icinga\Module\Map\ProvidedHook\Monitoring;

use Icinga\Module\Monitoring\DataView\Customvar;
use Icinga\Web\Controller\ModuleActionController;
use Icinga\Module\Monitoring\Hook\HostActionsHook;
use Icinga\Module\Monitoring\Object\Host;
use Icinga\Web\Navigation\Navigation;
use Icinga\Web\Navigation\NavigationItem;
use Icinga\Web\Url;

class HostActions extends HostActionsHook
{
    public function getActionsForHost(Host $host)
    {
        $nav = new Navigation();

        $host->fetchCustomvars();
        if (array_key_exists("geolocation", $host->customvars)) {
            $nav->addItem(new NavigationItem(t('Show on map'), array(
                'url' => Url::fromPath('map/', array('showHost' => $host->getName())),
                'target' => '_next',
                'icon' => 'globe',
            )));
        }

        return $nav;
    }
}