File: ServiceActions.php

package info (click to toggle)
icingaweb2-module-map 2.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 9,028 kB
  • sloc: javascript: 11,939; php: 1,207; sh: 54; makefile: 15
file content (26 lines) | stat: -rw-r--r-- 665 bytes parent folder | download | duplicates (2)
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
<?php

namespace Icinga\Module\Map\ProvidedHook\Icingadb;

use Icinga\Module\Icingadb\Hook\ServiceActionsHook;
use Icinga\Module\Icingadb\Model\Service;
use ipl\Web\Widget\Icon;
use ipl\Web\Widget\Link;

class ServiceActions extends ServiceActionsHook
{
    public function getActionsForObject(Service $service): array
    {
        if (! isset($service->vars['geolocation'])) {
            return [];
        }

        $label = mt('map', 'Show on map');
        return [
            new Link(
                [new Icon('globe'), $label],
                'map?showHost=' . rawurlencode($service->host->name . '!' . $service->name)
            )
        ];
    }
}