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

- Patch
- Review
- Test

User interface changes

None

API changes

None

Data model changes

None

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

akalam created an issue. See original summary.

akalam’s picture

Issue summary: View changes
Status: Active » Needs review

Added a new MR with the changes described above. Ready to review

barrio’s picture

Issue summary: View changes
akalam’s picture

Issue summary: View changes
heddn’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Adding a test plugin based menu item should be fairly easy to do and would be a great way to test this.

heddn’s picture

#3317493: Integrate into core menus is corollary work going on in this space. Just linking these 2.

akalam’s picture

MR rerolled against latest 1.x version