Problem/Motivation

The canonical, edit-form, and delete-form link templates on OgMenuInstance use /admin/ogmenu_instance/..., while the matching routes in og_menu.routing.yml use /admin/structure/ogmenu_instance/.... The add-link template is already correct.

This does not currently break routing because the entity has no route provider and toUrl() resolves the existing route names. However, the mismatch would create conflicting routes if a DefaultHtmlRouteProvider is added, such as when adding the collection route from #2992044: Add a list builder for OG Menu instances and replace the custom OverviewMenuInstances form. A similar inconsistency was fixed for the ogmenu config entity in #2994891: OgMenu collection link template is a 404.

Proposed resolution

Also align the OgMenu config entity link templates with its routes under /admin/structure/menu/ogmenu: fix the overview-form, edit-form, and delete-form paths; add the missing add-form template; and remove canonical, which has no corresponding route. Core config bundle entities such as Menu and NodeType likewise do not define a canonical link template, and toUrl() falls back to edit-form.

Remaining tasks

  • Add a kernel test confirming that every link template on both entity types matches the path of its corresponding route.

Issue fork og_menu-3624499

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

joelpittet created an issue. See original summary.

joelpittet’s picture

Issue summary: View changes

Pushed a follow-up to the MR extending the fix to the OgMenu config entity, which had the same mismatch: link templates under /admin/structure/ogmenu/... while its routes live under /admin/structure/menu/ogmenu/....

The change also adds the missing add-form template and removes canonical, which had no corresponding route and could cause a RouteNotFoundException if anything called toUrl('canonical'). Core's Menu and NodeType config entities do not define one either.

The kernel test is now OgMenuLinkTemplateTest, with a data provider covering both entity types. I also updated the issue summary to reflect the expanded scope.

Note for #2992044: Add a list builder for OG Menu instances and replace the custom OverviewMenuInstances form: !31 adds a collection template on the same lines of OgMenuInstance.php, so whichever lands second will need a trivial rebase. The new test will validate that template automatically.

joelpittet’s picture

Status: Active » Needs review

  • joelpittet committed e6564e7a on 2.x
    fix: #3624499 Align OgMenu and OgMenuInstance link templates with their...
joelpittet’s picture

Status: Needs review » Fixed

This feels safe to commit

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.