Menu Items Extras fields should be returned in correct translation

Created on 14 March 2024, 8 months ago
Updated 12 July 2024, 4 months ago

In issue https://www.drupal.org/project/rest_menu_items/issues/3039979 Menu Items Extras fields also returned by the API Fixed menu item extra fields are added to "Rest menu items". The implementation has been merged to current dev version.
The problem is, that only the default language values are returned instead of the current language version.
I tried to implement a fix - please review patch attached.

Added to function checkContentFields() after:

  $menu_link_content = $this->menuLinkContentStorage->load($id);

  if ($menu_link_content) {

the new lines:

  $lang_code = \Drupal::service('language_manager')->getCurrentLanguage()->getId();
  if ($menu_link_content->hasTranslation($lang_code)) {
    $menu_link_content = $menu_link_content->getTranslation($lang_code);
  }
🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇩🇪Germany vistree

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024