Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The following table summarises how to define dynamic items with the successors of hook_menu().
Type | To create dynamic elements | Docs | |
---|---|---|---|
Route | route_callbacks: entry in routing.yml that is a list of class names; HOWEVER if dependent on other routes, need to implement an event subscriber service (*.services.yml + custom class) with alterRoutes(). |
Docs | |
Menu link | Implement hook_menu_link_defaults_alter().
#2256521: [META] New plan, Phase 2: Implement menu links as plugins, including static admin links and views, and custom links with menu_link_content entity, all managed via menu_ui module proposes to add a solution to provide a 'fake' menu link in your *.menu_links.yml with a |
Docs | |
Local tasks | Add a 'fake' local task element in your *.local_tasks.yml file with a derivative key that points to a class implementing the actual dynamic local tasks. |
Docs | |
Local actions | Add a 'fake' local action element in your *.local_actions.yml file with a derivative key that points to a class implementing the actual dynamic local actions. |
Docs | |
Contextual links | Add a 'fake' contextual link element in your *.contextual_links.yml file with a derivative key that points to a class implementing the actual dynamic links. |
Docs |
Proposed resolution
Don't know.
Remaining tasks
Discuss.
User interface changes
None.
API changes
Maybe.
Comments
Comment #1
Gábor HojtsyComment #2
dawehnerA rainbow then consists of 2 colors.
Comment #3
Gábor Hojtsy@dawehner points out that #2256521: [META] New plan, Phase 2: Implement menu links as plugins, including static admin links and views, and custom links with menu_link_content entity, all managed via menu_ui module unifies dynamic menu links uses the same patterns as for local tasks/contextual links/actions for derivatives.
Comment #4
Gábor Hojtsy@daweher: one more good reason to get the menu issue in :)
Comment #5
effulgentsia CreditAttribution: effulgentsia commentedRoutes and Links are different. Is it so bad for them to have different patterns for creating dynamic ones? I agree that having the same pattern for the 4 link types is desirable, but just that much is a dupe of #2256521: [META] New plan, Phase 2: Implement menu links as plugins, including static admin links and views, and custom links with menu_link_content entity, all managed via menu_ui module, so then what becomes the goal of this issue?
Comment #6
Gábor HojtsyIf that is the extent we want to unify them, then this can be marked a duplicate.
Comment #7
xjmComment #8
Gábor HojtsyGiven nobody else concerned, let's close as duplicate of #2256521: [META] New plan, Phase 2: Implement menu links as plugins, including static admin links and views, and custom links with menu_link_content entity, all managed via menu_ui module.