File: SuggestController.php

package info (click to toggle)
icingadb-web 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,260 kB
  • sloc: php: 33,601; javascript: 640; sh: 17; xml: 16; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 1,629 bytes parent folder | download
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
31
32
33
34
35
36
37
38
39
40
41
<?php

/* Icinga DB Web | (c) 2025 Icinga GmbH | GPLv2 */

namespace Icinga\Module\Icingadb\Controllers;

use Icinga\Module\Icingadb\Model\Host;
use Icinga\Module\Icingadb\Model\Service;
use Icinga\Module\Icingadb\ProvidedHook\Notifications\V1\Source;
use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions;
use ipl\Web\Compat\CompatController;

class SuggestController extends CompatController
{
    public function restrictionColumnAction(): void
    {
        $suggestions = (new ObjectSuggestions())
            ->setModel(
                match ($this->params->getRequired('type')) {
                    'host', Source::TYPE_ALL => Host::class,
                    'service' => Service::class,
                    default => $this->httpBadRequest('Invalid type')
                }
            )
            ->onlyWithCustomVarSources(['host', 'service'])
            ->withFixedColumns([
                'host.name' => $this->translate('Host Name'),
                'hostgroup.name' => $this->translate('Hostgroup Name'),
                'host.user.name' => $this->translate('Contact Name'),
                'host.usergroup.name' => $this->translate('Contactgroup Name'),
                'service.name' => $this->translate('Service Name'),
                'servicegroup.name' => $this->translate('Servicegroup Name'),
                'service.user.name' => $this->translate('Contact Name'),
                'service.usergroup.name' => $this->translate('Contactgroup Name')
            ]);

        $this->getDocument()->addHtml(
            $suggestions->forRequest($this->getServerRequest())
        );
    }
}