From 7b64af59410f1a658c70b8be367156fc3f4da17c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:20:19 +0200 Subject: Adding upstream version 2.1.0. Signed-off-by: Daniel Baumann --- library/Generictts/Ticket.php | 71 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 library/Generictts/Ticket.php (limited to 'library/Generictts') diff --git a/library/Generictts/Ticket.php b/library/Generictts/Ticket.php new file mode 100644 index 0000000..b8ded1d --- /dev/null +++ b/library/Generictts/Ticket.php @@ -0,0 +1,71 @@ +config = $config; + + $ticketPatterns = array(); + foreach ($config as $section => $values) { + if ($values->get('url')) { // Skip integrations that don't contain a URL + $ticketPattern = $this->createTicketPattern($section, $values->get('pattern')); + if ($ticketPattern->isValid()) { // Skip integrations that don't contain a pattern + $ticketPatterns[$section] = $ticketPattern; + } + } + } + $this->ticketPatterns = $ticketPatterns; + } + + /** + * {@inheritdoc} + * + * @return \Icinga\Application\Hook\Ticket\TicketPattern[] + */ + public function getPattern() + { + return $this->ticketPatterns; + } + + /** + * {@inheritdoc} + */ + public function createLink($match) + { + /** @var \Icinga\Application\Hook\Ticket\TicketPattern $match */ + return sprintf( + '%s', + preg_replace('/\$1/', rawurlencode($match[1]), $this->config->get($match->getName(), 'url')), + $match[0] + ); + } +} -- cgit v1.2.3