Menu Items Extras fields should be returned in correct translation

Created on 14 March 2024, 4 months ago
Updated 29 March 2024, 3 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

Active

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.69.0 2024