In Drupal 8's implementation of `module_implements`, every module is looped over and then function_exists is called to see if a module has implemented a specific hook. This works however there are probably better ways for modules to announce they are implementing a hook.
I propose using `Drupal\Core\Extension\ModuleHandler` (or another class) to register hooks. Something like the following might be a typical use case:
drupal_container()->get('module_handler')->registerHook(
'menu',
function(){
return array(
..
);
}
);
I can see the following advantages:
- More performant, no need to loop through every module and check if a function exists.
- Doesn't fill global scope with unnecessary functions.
- Clearly draws a line between what is a function and what is a hook.
I haven't looked too deeply into Drupal 8, so any feedback or comments would be welcomed.