In Drupal 7, we have two ways to lazy-load procedural code:
1) page callbacks may be placed into an alternate file and loaded on demand via a specification in hook_menu(), theme functions may be lazy-loaded the same way via a specification in hook_theme() (although that seems rather fragile in practice), etc.
2) Hooks may be dynamically loaded via hook_hook_info().
The latter works, but is somewhat brittle and in practice the implementation is clunky. Not lazy-loading procedural code is no longer an option given the size of our codebase, but something more robust than the current hook_hook_info() implementation is necessary.
Discuss. :-) (But not until Drupal 7 is done. Anyone caught discussing this before Drupal 7 ships will be spanked with raw lasagna.)
Comments
Comment #1
sunInclude files are used a lot for page callbacks + theme callbacks - not sure what is considered "fragile" about that. Works for me.
Form callbacks may be placed into include files, too. See form_load_include().
Comment #2
Anonymous (not verified) commentedsubscribe. i like merlinofchaos' idea of declaring hooks. will try to get him to add that here.
Comment #3
Crell commentedhook_hook_info is declaring hooks. :-)
You've both now earned a pasta spanking.
Comment #4
andypostIf D8 would follow a butler's way I thing there's no need to maintain manual loading - each context should know exactly all files that needed.
Comment #5
sunDuplicate of #1107528: Stop using magic functions and force modules to declare the hooks they want to implement ?
Comment #6
sunThis issue appears to be obsolete with the new routing architecture.
For the remaining parts, marking as duplicate of
#1905334: Only load all modules when a hook gets invoked
#2233261: Deprecate hook_hook_info groups, mark hook_hook_info() for deletion