Detect Kulturhauptdorf events by tag name instead of tag ID 21
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
bd04ccc7b2
commit
5aeeee0ee5
1 file changed
+20
@@ -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<array<string, string>> $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<array<string, string>> */
|
||||
private function fetchTags(int $eventId): array
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user