mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Add SPDX license headers and mark source files as GPL-3.0-or-later to preserve the option to relicense under later GPL versions.
56 lines
1.2 KiB
PHP
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);
|
|
}
|
|
}
|