Problem/Motivation
This module started with only alter(), It would be good to support invoke and invokeAll although that may require many core patches.
The biggest problem to solve here is that core and contrib assume that hooks are always functions, and they construct their names with $module . '_' . $hook which makes it impossible for us.
Proposed resolution
- Rename HookInterface to AlterHookInterface
- Use HookInterface for invoke/invokeAll hooks and add a invoke() method to the interface.
- Ensure getImplementations() returns all the modules that implement OO hooks.
Remaining tasks
Decide how to handle the $function = $module . '_' . $hook pattern.
- Replace all occurrences with with $handler->invoke() calls (won't work for by reference)? Don't support people who don't use invoke()? document unsupported hooks?
- Use phpstorage to write a procedural function to disk as a shim between the function and the oo implementation.
- We could implement the wrappers manually for all core hooks that do this?
Comments
Comment #2
benjy commentedComment #3
benjy commentedComment #4
benjy commentedComment #5
benjy commentedComment #6
cweagansI don't think there's really any way around using PhpStorage or some other clever thing like that for the $module . '_' . $hook case until #2616814: Delegate all hook invocations to ModuleHandler is solved.
That's possibly a separate issue, though. Making ->invoke() and ->invokeAll() work should be reasonably straightforward, even if they aren't called appropriately in some cases.