icingadb-web/application/controllers/SuggestController.php
Eric Lippmann 272e791390 License source files as GPL-3.0-or-later
Add SPDX license headers and mark source files as GPL-3.0-or-later to
preserve the option to relicense under later GPL versions.
2026-03-11 14:03:05 +01:00

42 lines
1.6 KiB
PHP

<?php
// SPDX-FileCopyrightText: 2025 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
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())
);
}
}