4

Is it possible to get a list of defined hooks for debugging purposes?

I have implemented mymodule_datalayer_meta() for datalayer's hook_datalayer_meta(). However, as far as I can tell, it's not firing. I'd like to look up a list of hooks that modules implement so I can see if my module is actually implementing it or not.

4

You are looking for the module_implements function

Determines which modules are implementing a hook.

Use this function in the devel/php form, for example.

dpm(module_implements('THE_HOOK'));

This way you can see easily if your module implements 'THE_HOOK'.

| improve this answer | |
3

If you've got access to drush (and you want to use it), you can use drush hook menu (this is obviously for hook_menu)

| improve this answer | |
1

Hooks are not stored in the database, but they are actually cached into the table cache_bootstrap. See this answer for a clue on how to see a list of cached hooks.

| improve this answer | |
  • I've had a look at it, my cached hooks table appears to be empty: $> drush @site sqlc -A MariaDB [site_db]> select * FROM cache_bootstrap; Empty set (0.00 sec) – user1359 Nov 18 '15 at 17:13
  • Something is wrong. This table contains some basic records in all Drupal installations (like cached variables). I'm not too savvy about this, but perhaps you need to clear the cache so that everything is rebuilt? Do you have the right database? Perhaps your site is not using cache?? (not a good idea - drupal.stackexchange.com/questions/28340/…) – argiepiano Nov 18 '15 at 17:18
  • are you sure this cache table isn't cleared after a cache clear? – user1359 Nov 18 '15 at 17:20
  • The cache is cleared, but from what I'm seeing right now (I'm testing this as we speak) there are several records in that table that are rebuilt with every cache clearing, including system_list, variables, boostrap_modules, etc – argiepiano Nov 18 '15 at 17:24
  • Not sure what's going on, site seems to work okay :S – user1359 Nov 18 '15 at 18:13
0

The PhpStorm IDE can also tell you where a hook is used (= implemented).

  • Click on the arrow up left to your hook implementation to go to the hook documentation in an .api file and there you can click on the arrow down to see all implementations of it.
| improve this answer | |

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.