-
-
Notifications
You must be signed in to change notification settings - Fork 18
Hook listeners
Hooks are invoked by the core code as $hooks->cat('action');
(replace action as appropriate). To respond, a hook listens for the action to be called. This is sometimes called a Publish/Subscribe model. The listener functions are the subscribers. And each call
or generate
publishes to all subscribers.
File-based hooks do this with methods named listen_action
(again replace action with the actual label). E.g. a file-based system hook would be listen_startApplication
. A database hook listens for the defined hooks_action.
You may need to say $hooks
, $GLOBALS['hooks']
, $admin_hooks
, or $GLOBALS['admin_hooks']
depending on where you are.
In admin, each action has an associated hook. I.e. each file in admin/includes/actions/page_name/*.php has an action with the file name converted to a hook name. E.g. admin/includes/actions/manufacturers/insert.php would be listen_insertAction
and accessed from a URL admin/manufacturers.php?action=insert (or whatever name your admin folder uses). The action is defined as a GET parameter, even though most of them must be invoked by form POST.