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

sun’s picture

Include 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().

Anonymous’s picture

subscribe. i like merlinofchaos' idea of declaring hooks. will try to get him to add that here.

Crell’s picture

hook_hook_info is declaring hooks. :-)

You've both now earned a pasta spanking.

andypost’s picture

If 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.

sun’s picture

sun’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)

This 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