Support menu_manipulator for language filtering

Created on 23 May 2022, over 2 years ago
Updated 26 July 2023, over 1 year ago

Problem/Motivation

Superfish block implements its own logic to build menus from within its Block (e.g. Drupal\superfish\Plugin\Block\Superfish::build()).

Consequence: other modules relying on the default menu rendering pipeline/preprocess do not work.

Example is this issue Support Superfish Fixed .
with the menu_manipulator module to filter menus by language.

Proposed resolution

I suggest to test wether or not the module exists and if so, to use the manipulator it provides to filter Superfish menu.

    // line 1537
    $tree = $this->menuTree->load($menu_name, $parameters);
    $manipulators = [
      ['callable' => 'menu.default_tree_manipulators:checkAccess'],
      ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
    ];
    if ($this->moduleHandler->moduleExists('menu_manipulator')) {
      $manipulators[] = ['callable' => 'menu_manipulator.menu_tree_manipulators:filterTreeByCurrentLanguage'];
    }
    $tree = $this->menuTree->transform($tree, $manipulators);
    // ...
📌 Task
Status

Fixed

Version

1.0

Component

Code

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024