From 429b5fc46a22b84d20e11acb913992b94fea6fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Lochm=C3=BCller?= Date: Wed, 20 Nov 2024 21:57:59 +0100 Subject: [PATCH] Fix call of getTwoLetterIsoCode --- Classes/Negotiation/DefaultNegotiation.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Classes/Negotiation/DefaultNegotiation.php b/Classes/Negotiation/DefaultNegotiation.php index bbcec4a..8bf3159 100644 --- a/Classes/Negotiation/DefaultNegotiation.php +++ b/Classes/Negotiation/DefaultNegotiation.php @@ -13,19 +13,18 @@ public function __construct(protected Normalizer $normalizer) {} public function __invoke(NegotiateSiteLanguageEvent $event): void { - $compareWith = [ - 'getLocale', - 'getTwoLetterIsoCode', - ]; - $userLanguages = $this->normalizer->normalizeList($event->getUserLanguages()); foreach ($userLanguages->toArray() as $userLanguage) { foreach ($event->getSite()->getLanguages() as $siteLanguage) { - foreach ($compareWith as $function) { + $compareWith = [ + (string)$siteLanguage->getLocale(), + $siteLanguage->getLocale()->getLanguageCode(), + ]; + foreach ($compareWith as $value) { $config = $siteLanguage->toArray(); if ($siteLanguage->enabled() && ($config['excludeFromLanguageDetection'] ?? false) !== true - && (string)$userLanguage === $this->normalizer->normalize((string)$siteLanguage->{$function}()) + && (string)$userLanguage === $this->normalizer->normalize($value) ) { $event->setSelectedLanguage($siteLanguage);