Problem/Motivation

Superfish menu block allows menu tree to be altered/manipulated by core and contrib manipulators.

Here's the code:

    $tree = $this->menuTree->load($menu_name, $parameters);

    $manipulators = [
      ['callable' => 'menu.default_tree_manipulators:checkAccess'],
      ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
    ];

    if ($this->moduleHandler->moduleExists('translatable_menu_link_uri')) {
      $manipulators[] = ['callable' => 'superfish.translatable_menu_link_manipulator:transform'];
    }

    // Alter tree manipulators.
    $this->moduleHandler->alter('superfish_tree_manipulators', $manipulators, $menu_name, $tree);

    if ($this->moduleHandler->moduleExists('menu_manipulator')) {
      $manipulators[] = ['callable' => 'menu_manipulator.menu_tree_manipulators:filterTreeByCurrentLanguage'];
    }
    $tree = $this->menuTree->transform($tree, $manipulators);

Manipulating the tree can be expensive and it happens on every page load, which might not be necessary.

Proposed resolution

Cache the menu tree.
Caching it directly might not be the best idea. We might provide a config that enables user to cache the menu tree.

Remaining tasks

Discuss and fix.

User interface changes

API changes

Data model changes

Issue fork superfish-3570260

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dipakmdhrm created an issue.

dipakmdhrm’s picture

I've added a PoC MR.