icingadb-web/library/Icingadb/View/HostRenderer.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

34 lines
1 KiB
PHP

<?php
// SPDX-FileCopyrightText: 2025 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
namespace Icinga\Module\Icingadb\View;
use Icinga\Module\Icingadb\Common\Links;
use Icinga\Module\Icingadb\Model\Host;
use ipl\Html\Attributes;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Html\ValidHtml;
use ipl\Web\Widget\Link;
/** @extends BaseHostAndServiceRenderer<Host> */
class HostRenderer extends BaseHostAndServiceRenderer
{
public function assembleAttributes($item, Attributes $attributes, string $layout): void
{
parent::assembleAttributes($item, $attributes, $layout);
$attributes->get('class')->addValue('host');
}
protected function createSubject($item, string $layout): ValidHtml
{
if ($layout === 'header') {
return new HtmlElement('span', new Attributes(['class' => 'subject']), new Text($item->display_name));
}
return new Link($item->display_name, Links::host($item), ['class' => 'subject']);
}
}