Drupal 10: Use Drush To Print Out All Implementations Of A Hook

Use this Drush snippet to print out a list of all of the implementations of a hook in your Drupal site.

This will print out all of the "hook_cron" hooks using the property of "cron" in the getImplementations() method of the Drupal module handler.

drush php-eval 'foreach (\Drupal::moduleHandler()->getImplementations("cron") as $value){echo "$value\n";}'

This will print out something like the following (depending on what modules you have installed).

comment
dblog
field
file
node
system
update

You can do the same with any hook on your site, hook_form_alter() for example.

drush php-eval 'foreach (\Drupal::moduleHandler()->getImplementations("form_alter") as $value){echo "$value\n";}'

 

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
3 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.