Support plugin based menu links on group content menus

Created on 26 July 2021, almost 4 years ago
Updated 4 September 2023, almost 2 years ago

Problem/Motivation

Currently the group content menu presumes all menu links are menu content link entities, what happens in most situations but not always.
As consequence, when you add a plugin based menu link, and go to edit the menu, you get the following error message:

Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "menu_link_content" for route "entity.group_content_menu.edit_link" must match "[^/]++" ("" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 204 of core/lib/Drupal/Core/Routing/UrlGenerator.php).
Drupal\Core\Routing\UrlGenerator->getInternalPathFromRoute('entity.group_content_menu.edit_link', Object, Array, Array) (Line: 293)
Drupal\Core\Routing\UrlGenerator->generateFromRoute('entity.group_content_menu.edit_link', Array, Array, 1) (Line: 105)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('entity.group_content_menu.edit_link', Array, Array, 1) (Line: 762)
Drupal\Core\Url->toString(1) (Line: 182)
Drupal\Core\Utility\LinkGenerator->generate(Object, Object) (Line: 95)
Drupal\Core\Render\Element\Link::preRenderLink(Array)

Steps to reproduce

- Create a plugin based menu link. See: https://www.drupal.org/docs/drupal-apis/menu-api/providing-module-define...
- In the yaml definition, set the menu name properly. The group menu name will be GroupContentMenuInterface::MENU_PREFIX . $menu_group_content_id
- Go to your group > group menus > your menu > edit
- You will see the error above.

Proposed resolution

The error is caused by the code generating the operations, specifically the code generating the edit operation. Checking if the menu link is an instance of MenuLinkContentInterface should do the trick.

Remaining tasks

-
- Review
- Test

User interface changes

None

API changes

None

Data model changes

None

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇪🇸Spain akalam

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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