mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-04-13 12:56:25 -04:00
TicketLinks: Add setter to disable ticket links. By default, ticket links should be created. Comment/DowntimeRenderer: Add setter noObjectLink() CommentRenderer: Add setter noSubjectLink(), only used for the comment-popup
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
/* Icinga DB Web | (c) 2022 Icinga GmbH | GPLv2 */
|
|
|
|
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);
|
|
}
|
|
}
|