Spinoff from #1889790: [Meta] Allow modules to register links for menus, breadcrumbs and tabs (if not with hook_menu):
We rip action links out of hook_menu entirely, using essentially the model from #1889790-9: [Meta] Allow modules to register links for menus, breadcrumbs and tabs (if not with hook_menu). To wit, action links become their own object unto themselves that reference to a route they point TO, and to routes they should appear ON. They are then removed from hook_menu entirely. We then build a block that looks at the current route (which may need to be passed as a literal string, not pulled from the request, TBD), grabs the action links that should be on that route, and displays them. Want to change the L&F? It's a block. Enjoy.
Benefit: Action links get separated from hook_menu, where they didn't belong in the first place.
Comment | File | Size | Author |
---|---|---|---|
#26 | local-action-1908756-26.patch | 10.49 KB | tim.plunkett |
#26 | interdiff.txt | 4.14 KB | tim.plunkett |
#24 | action-links-1908756-24.patch | 12.69 KB | tim.plunkett |
#24 | interdiff.txt | 1.5 KB | tim.plunkett |
#17 | local-action-1908756-17.patch | 11.77 KB | tim.plunkett |
Comments
Comment #1
tim.plunkettThe meta issue is major, we don't need this to be as well.
Comment #2
mtiftI'll take this one
Comment #3
tim.plunkettComment #4
mtiftSo I'm really not sure where to go with this one. For example, I don't even know where MENU_LOCAL_ACTION will go when we rip it out, or what interface/class to implement/extend. Sorry...
Comment #5
Crell CreditAttribution: Crell commentedIt's all new classes, likely culminating in a block is my guess. The idea is that MENU_LOCAL_ACTION ceases to exist. See the linked comment for background.
Comment #6
tim.plunkettI just spent a good amount of time with local actions thanks to #1938960: _menu_translate() doesn't care about new routes, going to take a look
Comment #7
tim.plunkettViews UI is the only hook_menu() whose MENU_LOCAL_ACTIONs are routes that reference other paths that are routes. More conversions will have to follow.
To do this, I had to clean up _menu_router_merge_route().
It has been tweaked over time, and currently takes a $path and discards it directly.
Also, the entire point of the function is to populate the path from a route name.
So I've renamed it and repurposed it for just that.
This contains #1938960: _menu_translate() doesn't care about new routes.
Comment #8
Crell CreditAttribution: Crell commentedAt a quick glance, this seems like a reasonable start. I'm sad that it's a hook, but not sure what the alternative is. :-(
I'm a bit concerned about using the target route name as the key; I've a gut feeling (no data at the moment) that it's going to end up biting us somehow. Also, the "route" key in the array should probably be more descriptive. "Appears_On" wouldn't fit any known standard, but something more like that so that it's more self-documenting, perhaps?
Comment #9
tim.plunkettIt's so sad, I've worked so hard to kill off info hooks this cycle, yet this would mark the third new info hook I'm responsible for...
I'll mull over the naming while I write a test.
Comment #11
tim.plunkettOkay, made the switch to 'appears_on', and here's a test.
Comment #12
larowlanI can only see nitpicks here
module_invoke_all deprecated?
Implements
Comment #13
tim.plunkettGood catch!
Converted picture and aggregator since there were move conversions committed.
Comment #15
tim.plunkettPostponed on http://drupal.org/project/issues/search/drupal?issue_tags=MENU_LOCAL_ACTION
Comment #16
dawehnerThere is just a single place there this function is used so we maybe can move this into some kind of object already?
Comment #17
tim.plunkettOkay. MENU_LOCAL_ACTION does two things.
This issue is just about the former. It does not let us remove the hook_menu() definition.
But to better differentiate these two things, we *can* start converting now, and just have an identical bitmask menu type with a different name.
Introducing MENU_SIBLING_LOCAL_TASK.
Let's see how it fares.
---
@dawehner, I'm not sure what that would look like, especially with the menu_get_item() and menu_local_tasks() calls.
Comment #22
tim.plunkettHere is my reasoning for introducing a duplicated constant (MENU_SIBLING_LOCAL_TASK and MENU_LOCAL_ACTION have the same value):
We are attempting to replace the display of menu local actions on their parent page (the functionality of
menu_local_actions()
)We are NOT attempting to rewrite
_menu_router_build()
, where it checks hook_menu() in order to build the breadcrumbs and decide what tabs to show on the action's page itself.Once this issue is in, and all existing MENU_LOCAL_ACTIONs are converted, we will still be left with a hook_menu() entry for that. Yet it will not be for anything action-related, just about its behavior as a pseudo-local-task. Hence MENU_SIBLING_LOCAL_TASK.
The added benefit will be knowing which actions remain (since they will have the old constant).
Comment #23
Crell CreditAttribution: Crell commentedDocblock is out of date. Should say "appears_on", not "routes".
Tim's explanation of the new/renamed constant makes sense. It's basically just there for breadcrumbs/tabs while viewing the route that is the local action. I am not convinced MENU_SIBLING_LOCAL_TASK is the best name for it, but... hard problems.
Otherwise this works for me.
Comment #24
tim.plunkettFixed the docs, and added another conversion.
Comment #25
dawehnerMaybe we should come later here, as this maybe not scale if there are a lot of local actions defined.
maybe it would be nice to have some access checking on there ...
... We want to be able to translate the title ...
Let's move the route_name to the definition, as it's for example more consistent to the way hook_menu looks at the moment.
Comment #26
tim.plunkettFixed all of those but the first, where I added a @todo to consider adding static caching later.
Comment #27
dawehnerI will not bitch about silly spaces!
Good idea!
Comment #28
tim.plunkett#26: local-action-1908756-26.patch queued for re-testing.
Comment #29
alexpottCommitted 00fdcd3 and pushed to 8.x. Thanks!
Comment #30
tstoecklerAny specific reason why this was changed from hook_local_action_info()? It seems the latter is a standard throughout core, that would make sense following here, IMO.
Comment #31
tim.plunkettWe're actually in the midst of killing info hooks. In the above patches it was named that, I was asked to rename it at Drupalcon.
Comment #32
tstoecklerHmm... still seems strange to not apply an existing pattern just because the whole concept is sort of deprecated-ish. Not a big deal, either way, though, so I'll shut up.
Comment #33
tim.plunkettOpened #2006624: Implement LocalAction plugins for previously converted routes
Comment #34
tim.plunkettAdded https://drupal.org/node/2007444
Comment #35
jibranChange notice looks good.