Menu per role config is not exported with the menu config

Created on 28 April 2023, over 1 year ago
Updated 6 January 2024, 11 months ago

Problem/Motivation

When I have Menu Per role module installed, I can not export the permission config with the menus and subsequently can not import it.

Proposed resolution

We should add the menu per role show field in Menus Controller and it should fix the problem.

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇮🇳India snpatel2263

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

Comments & Activities

  • Issue created by @snpatel2263
  • 🇮🇳India snpatel2263

    I have created the page keeping in mind the suggestions I added please test and update the issue for further development.

  • 🇮🇳India snpatel2263

    The previous patch was not applying properly so new patch file.

  • 🇮🇳India snpatel2263

    updated the patch file to further update the functionality.

  • 🇮🇳India snpatel2263

    Added dependency on menu_per_role module so the patch does not break anything.

  • 🇮🇳India Yseakshay77

    I am using Custom Menu Links Visibility Module, I can not export the permission config with the menus and subsequently can not import it.
    module link https://www.drupal.org/project/menu_link_content_visibility

  • Issue was unassigned.
  • 🇫🇷France dydave

    Hi everyone,

    Thank you very much for raising this issue and for contributing a patch, it's greatly appreciated.

    Just a quick comment to mention this issue seems to be related to New fields added to the menu cannot be exported Needs review where a more generic approach is suggested for supporting in structure_sync import/export of any additional data added by other modules, whether contrib or custom, to Menu Link content items.

    Since Menu Per Role isn't a core module and structure_sync doesn't really require it, there would be many cases where this config key wouldn't necessarily have any use, thus making this patch and config key 'menu_per_role__show_role' a bit unnecessary/useless.
    Therefore, we could perhaps suggest implementing this feature directly in module menu_per_role:menu_per_role, with implementations of the hooks added in the patch from related issue with an example of a custom implementation at #2980893-13: New fields added to the menu cannot be exported .

    However, this would certainly depend on the way maintainers choose the module should evolve, reviews/feedback on adding additional hooks ( #2980893 New fields added to the menu cannot be exported Needs review ), before really being able to take this feature any further.

    Otherwise, in terms of code, it could be something like adding implementations of added hooks to import/export the necessary config key 'menu_per_role__show_role' (in menu_per_role.module) and perhaps a config schema type definition for the validation of the key added to the structure_sync.data config.
    This could perhaps be done with a patch to the Menu Per Role module, to integrate with structure_sync, either directly in the menu_per_role.module file or in a sub-module (for example, menu_per_role:menu_per_role_structure_sync with a dependency on structure_sync:structure_sync - perhaps a bit cleaner).
    If the structure_sync module isn't installed, then the hooks would just be ignored, having no impact whatsoever on the module.

    The same goes for #6 (@Yseakshay77) and the support of the Custom Menu Links Visibility module with its added key 'visibility' (see MenuLinkContentVisibilityChecker.php, line 49, for example).

    Not sure if this alternate solution would make sense to you, but in any case, we would greatly appreciate if you could please try testing the suggested patch (!MR20), give us your reviews and opinions on the approach taken in this related ticket New fields added to the menu cannot be exported Needs review .

    Feel free to let us know at any point if you have any questions or concerns on any aspects of that patch, this reply or the ticket in general, we would surely be very happy to help.
    Thanks again very much for all your code contributions and in advance for your feedback.

Production build 0.71.5 2024