#2339 - Tidy up hook call pattern
| Identifier | #2339 |
|---|---|
| Issue type | Feature request or suggestion |
| Title | Tidy up hook call pattern |
| Status | Completed |
| Handling member | Chris Graham |
| Addon | core |
| Description | We currently do like...
$hooks = find_all_hooks('systems', 'SOME_HOOK_TYPE'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/SOME_HOOK_TYPE/' . $hook); $ob = object_factory('Hook_SOME_HOOK_TYPE_' . $hook); $ob->DO_SOMETHING(); } We would instead do like... $hooks = instantiate_all_hooks('systems', 'SOME_HOOK_TYPE'); foreach ($hooks as $ob) { $ob->DO_SOMETHING(); } Implement the API for this, then apply throughout our code. Allow the old mechanism to work still though, find_all_hooks is still a useful function that instantiate_all_hooks can use. |
| Steps to reproduce | |
| Funded? | No |
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".


Comments
However, I don't like the performance implications. For each hook type we'd need to load up another file that defines the interface, then PHP would need to check interface rules at run-time. That's actually not at all trivial - if you consider a page using 20 hook types, that's 20 extra PHP files loaded. So I think it's best to leave that. It makes more sense for compiled languages.