This module is an interesting idea!

I see that it only watches .module files though:

    $finder->files()
      ->name('*.module')
      ->in(DRUPAL_ROOT . '/modules/');

However hook implementations can live in several other files:

  • .theme files
  • .profile files
  • .install files
  • Files named according to "hook groups" defined in hook_hook_info() implementations. For hook groups defined by Drupal core, that means:
    • .tokens.inc files
    • .views.inc files
    • .views_execution.inc files

    However any contrib module can also define hook groups too.

Comments

andrewmacpherson created an issue. See original summary.

prudloff’s picture

Thanks for the suggestion!
I didn't want to watch too many files because it could ruin performances but these should be OK.

  • prudloff committed c0df910 on 1.x
    Issue #3175882: Find hook implementations when files other than .module...
prudloff’s picture

Status: Active » Fixed
andrewmacpherson’s picture

Would you consider adding the .inc files from the core hook groups too? These are widely used by various popular contrib modules: pathauto, redirect, diff, entity_reference_revisions, address. They are also used widely in Drupal core itself.

The *.views_execution.inc file is one I've frequently seen used in custom modules, to provide project-specific tweaks. (Far less so for the *.tokens.inc and *.views.inc.)

prudloff’s picture

I added every registered hook group.
This loop gets every hook group then adds the corresponding .inc file to the watcher.

andrewmacpherson’s picture

Great! That approach looks robust.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.