Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
hook_hook_info() allows modules that "own" a hook to specify that other modules may put the hook implementations into include files that are loaded on demand.
This especially makes sense for hook_content_migrate_*()
hooks, which are needed once only.
You can see an optimized implementation of hook_hook_info() in #1165388-7: Add mollom_hook_info() to offload Mollom hooks into modulename.mollom.inc:
/**
+ * Implements hook_hook_info().
+ */
+function mollom_hook_info() {
+ $hooks = array(
+ 'mollom_form_list',
+ 'mollom_form_list_alter',
+ 'mollom_form_info',
+ 'mollom_form_info_alter',
+ 'mollom_form_insert',
+ 'mollom_form_update',
+ 'mollom_form_delete',
+ 'mollom_data_insert',
+ 'mollom_data_update',
+ 'mollom_data_delete',
+ );
+ $hooks = array_fill_keys($hooks, array(
+ 'group' => 'mollom',
+ ));
+ return $hooks;
+}
Comment | File | Size | Author |
---|---|---|---|
#2 | cck.hook-info.2.patch | 767 bytes | sun |
Comments
Comment #1
sunThird-party modules need to implement these hooks, and they are dead code after migration, but yet, the code is loaded on all requests for no benefit.
Comment #2
sunAttached patch allows modules to implement the alter hooks in
$module.content_migrate.inc
Comment #3
DamienMcKenna