Menu plugins are an area where entity types that wish to provide a UI have a lot of boilerplate code. Three YML files have to be provided:
- MODULE.links.menu.yml
- MODULE.links.task.yml
- MODULE.links.action.yml
These contain repetitive boilerplate code, where furthermore it's very easy to make a mistake and match up the route names incorrectly.
Proposed solution:
- add a new handler type for entities, 'link_provider'
- add two new handler classes to the Entity component:
-- DefaultContentEntityLinkProvider
-- DefaultConfigEntityLinkProvider
- add plugin derivers for menu, task, and action plugins. These each loop over all entity types, and invoke the link_provider handler on any entity type that has one.
Core's default link provider handler classes would expect to find the route names created by core's route_provider classes. Entity types that customize their route provider to change or add routes would need to use their own link_provider handler (or keep using hardcoded link plugins of course).