Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-8088: Fetch english external menus for alternative languages. #31

Merged
merged 8 commits into from
May 11, 2023
9 changes: 8 additions & 1 deletion src/Plugin/Block/ExternalMenuBlockBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,17 @@ public function build() : array {

$menuTree = NULL;

// Currently only Finnish, English and Swedish have standard support.
// Other languages should default to English external menus for now.
$langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId();
if (!in_array($langcode, ['fi', 'en', 'sv'])) {
$langcode = 'en';
}

try {
$menuId = $this->getDerivativeId();
$response = $this->apiManager->get(
$this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(),
$langcode,
$menuId,
);
$menuTree = $this->menuTreeBuilder
Expand Down