From d6a10bdb9f4a02960f6c3cf7eec3306d1cdb1e50 Mon Sep 17 00:00:00 2001 From: "lina.wolf" Date: Mon, 21 Oct 2024 14:05:33 +0200 Subject: [PATCH] [TASK] Allow issue links to bitbucket --- .../src/Twig/TwigExtension.php | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/packages/typo3-docs-theme/src/Twig/TwigExtension.php b/packages/typo3-docs-theme/src/Twig/TwigExtension.php index 84175a053..220b008a4 100644 --- a/packages/typo3-docs-theme/src/Twig/TwigExtension.php +++ b/packages/typo3-docs-theme/src/Twig/TwigExtension.php @@ -342,8 +342,17 @@ public function getReportIssueLink(array $context): string if (str_starts_with($reportButton, 'https://gitlab.com/')) { return $reportButton; } + if (str_starts_with($reportButton, 'https://bitbucket.org/')) { + $reportButton = $this->enrichBitbuckedReport($reportButton, $renderContext); + return $reportButton; + } if ($reportButton !== '') { - $this->logger->warning('For security reasons only only "report-issue" links in the guides.xml to a local page (starting with "/") or to one of these 3 plattforms are allowed: https://forge.typo3.org/ https://github.com/ https://gitlab.com/'); + $this->logger->warning( + 'For security reasons only "report-issue" links in the guides.xml + to a local page (starting with "/") or to one of these 4 platforms + are allowed: https://forge.typo3.org/ https://github.com/ https://gitlab.com/ + https://bitbucket.org/' + ); return ''; } @@ -372,10 +381,6 @@ public function getReportIssueLink(array $context): string return ''; } - /** - * @param string $reportButton - * @return string - */ public function enrichGithubReport(string $reportButton, RenderContext $renderContext): string { if (str_ends_with($reportButton, '/issues')) { @@ -389,6 +394,21 @@ public function enrichGithubReport(string $reportButton, RenderContext $renderCo return $reportButton; } + + + private function enrichBitbuckedReport(string $reportButton, RenderContext $renderContext): string + { + if (str_ends_with($reportButton, '/issues')) { + $reportButton .= '/new'; + } + if (str_ends_with($reportButton, '/new')) { + $reportButton .= '?title='; + $description = $this->getIssueTitle($renderContext); + $reportButton .= urlencode($description); + } + return $reportButton; + } + /** * @param string $reportButton * @param RenderContext $renderContext