From 7030adc355dbaa2f65a9293370c257999d645cb2 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Sun, 6 Oct 2024 12:59:26 -0400 Subject: [PATCH] terminate early --- classes/MLPage.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/classes/MLPage.php b/classes/MLPage.php index 83d1101..809cb41 100644 --- a/classes/MLPage.php +++ b/classes/MLPage.php @@ -19,10 +19,9 @@ class MLPage public static function resolveMenuItem(object $item, string $url, Theme $theme): ?array { $result = CmsPage::resolveMenuItem($item, $url, $theme); + $locales = Locale::listEnabled(); - if ($result && ($page = CmsPage::loadCached($theme, $item->reference))) { - - $locales = Locale::listEnabled(); + if (count($locales) > 1 && $result && ($page = CmsPage::loadCached($theme, $item->reference))) { $defaultLocale = Locale::getDefault(); $alternateLinks = []; @@ -31,7 +30,7 @@ public static function resolveMenuItem(object $item, string $url, Theme $theme): $alternateLinks[$locale] = Url::to($pageUrl); } - if (count($alternateLinks) > 1) { + if ($alternateLinks) { $result['alternateLinks'] = $alternateLinks; } }