9

I'm somewhat new to module development.

Is there a way to currently output what hooks have been run on certain nodes?

Would this be done with xdebug?

9

Unless you get a fatal error (or blank screen) it's pretty easy to get a list of modules that will invoked when a special hook is called:

$modules = module_implements($hook);
foreach ($modules as $key =>  $module) {
  $function = $module . '_' . $hook;
  if (!function_exists($function)) {
    unset($modules[$key]);
  }
}
// $modules is now an array containing all the modules that will be invoked by $hook.

You could use stuff like xDebug to track the flow of the Drupal, but this can be overwhelming, especially if you are new to Drupal.

  • 1
    If you would like to try debugging and don't want to spend hours setting it up, you can try Quickstart. It is a virtual machine and with drush it is very easy to setup a site, then put in your module, import in Netbeans and hit debug. – Whiskey Jan 30 '12 at 20:11
  • 1
    Wouldn't this just show all modules that implement a particular hook, not all hooks that have Drupal has called up to that point? The later is how I read @chrisjlee's request. – mpdonadio Jan 30 '12 at 22:09
  • 1
    @MPD It will not just show which modules implement a hook but also the order in which they are called. If the context is what happens before/after my module's hook is called, the above will suffice. If you wanted to figure out if hook foo is called at a certain moment in the execution flow, it will be quite hard to figure out, since Drupal is so complex. Especially for a new developer. I'm unsure if this is what OP needs, but it's probably more useful than any xDebug suggestions anyways. – googletorp Jan 31 '12 at 8:14

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.