From 5aeeee0ee5941b5d23ab3997dd32fe3c26bfcd58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Mummert?= Date: Wed, 4 Nov 2026 15:32:11 +0100 Subject: [PATCH] Detect Kulturhauptdorf events by tag name instead of tag ID 21 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The event detail template data set has_tag_21 to drive the Kulturhauptdorf logo, but tag 21 is "Feste & Märkte", so the logo showed on every market/festival event. Add is_kulturhauptdorf, which checks for a tag named "Kulturhauptdorf" (case-insensitive), and keep has_tag_21 as deprecated for backwards compatibility. Co-Authored-By: Claude Opus 5.5 --- .../EventFullTemplateDataListener.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/EventListener/EventFullTemplateDataListener.php b/src/EventListener/EventFullTemplateDataListener.php index c44fcd6..a3410bc 100644 --- a/src/EventListener/EventFullTemplateDataListener.php +++ b/src/EventListener/EventFullTemplateDataListener.php @@ -13,6 +13,8 @@ use Doctrine\DBAL\ParameterType; #[AsHook('parseTemplate', method: 'onParseTemplate')] class EventFullTemplateDataListener { + private const KULTURHAUPTDORF_TAG = 'Kulturhauptdorf'; + public function __construct( private readonly Connection $connection, ) { @@ -42,6 +44,10 @@ class EventFullTemplateDataListener $template->location_row = $locationRow; $template->organizations = $organizations; $template->tags = $tags; + $template->is_kulturhauptdorf = $this->hasTagNamed($tags, self::KULTURHAUPTDORF_TAG); + + // Deprecated: Tag 21 ist "Feste & Märkte", nicht Kulturhauptdorf. Nur noch aus + // Kompatibilitätsgründen gesetzt; für das Kulturhauptdorf-Logo is_kulturhauptdorf verwenden. $template->has_tag_21 = \in_array(21, array_map(static fn (array $tag): int => (int) ($tag['id'] ?? 0), $tags), true); if ($locationRow && '' !== ($locationRow['lng'] ?? '') && '' !== ($locationRow['lat'] ?? '') && 58 !== (int) ($locationRow['id'] ?? 0)) { @@ -121,6 +127,20 @@ class EventFullTemplateDataListener return $organizations; } + /** @param list> $tags */ + private function hasTagNamed(array $tags, string $name): bool + { + foreach ($tags as $tag) { + foreach ([$tag['tag'] ?? '', $tag['title'] ?? ''] as $value) { + if (0 === strcasecmp(trim((string) $value), $name)) { + return true; + } + } + } + + return false; + } + /** @return list> */ private function fetchTags(int $eventId): array {