icingadb-web/library/Icingadb/Common/TicketLinks.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

56 lines
1.2 KiB
PHP

<?php
// SPDX-FileCopyrightText: 2022 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
namespace Icinga\Module\Icingadb\Common;
use Icinga\Application\Hook;
use Icinga\Application\Hook\TicketHook;
trait TicketLinks
{
/** @var bool Whether the ticket link is disabled */
protected $ticketLinkDisabled = false;
/**
* Set whether the ticket link is disabled
*
* @param bool $state
*
* @return $this
*/
public function setTicketLinkDisabled(bool $state = true): self
{
$this->ticketLinkDisabled = $state;
return $this;
}
/**
* Get whether the ticket link is disabled
*
* @return bool
*/
public function isTicketLinkDisabled(): bool
{
return $this->ticketLinkDisabled;
}
/**
* Get whether list items should render host and service links
*
* @return string
*/
public function createTicketLinks($text): string
{
if ($this->isTicketLinkDisabled() || ! Hook::has('ticket')) {
return $text ?? '';
}
/** @var TicketHook $tickets */
$tickets = Hook::first('ticket');
return $tickets->createLinks($text);
}
}