3

As a beginning developer, it seems like I spend a significant percentage of my time googling to find out what hook to call in order to modify something before it renders.

In the drupal 7.33 release, the theme debug mode was introduced, which provides contextual information in the page's HTML to theme developers and can be accessed by setting the theme_debug variable to TRUE.

Obviously there is no hook debug mode supported in core, but is anyone aware of a module that would provides contextual information about attempted hook calls, similar to how theme debug mode displays theme suggestion attempts?

Specifically, I am wondering if there is a module that would generate a list of every call to drupal_alter(), module_invoke_all(), or module_invoke(), along with the $type, $module, and/or $hook arguments supplied to these functions.

1

You could create a custom module and use hook_module_implements_alter which takes two arguements - $implementations and $hook.

Try this:

function MODULE_module_implements_alter(&$implements, $hook) {
  if ($hook == 'form_alter') {
    print_r($implementations);
  }
}

This will print out a list of all the implementations, in order, for hook_form_alter.

  • Good answer, but it won't work for calls to module_invoke(), which doesn't use module_implements(). I might be wrong, but I think a couple of core patches would be the only way to reliably get what the OP wants – Clive Apr 24 '15 at 12:46
  • I would never recommend modifying the core :) – Scott Joudry Apr 29 '15 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.