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.

0

1 Answer 1

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.

2
  • 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, 2015 at 12:46
  • I would never recommend modifying the core :) Apr 29, 2015 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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