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

  1. Rename HookInterface to AlterHookInterface
  2. Use HookInterface for invoke/invokeAll hooks and add a invoke() method to the interface.
  3. Ensure getImplementations() returns all the modules that implement OO hooks.

Remaining tasks

Decide how to handle the $function = $module . '_' . $hook pattern.

  1. 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?
  2. Use phpstorage to write a procedural function to disk as a shim between the function and the oo implementation.
  3. We could implement the wrappers manually for all core hooks that do this?

User interface changes

API changes

Data model changes

Comments

benjy created an issue. See original summary.

benjy’s picture

Issue summary: View changes
benjy’s picture

Issue summary: View changes
benjy’s picture

Issue summary: View changes
benjy’s picture

Version: » 8.x-1.x-dev
Issue summary: View changes
cweagans’s picture

I 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.