Extensions are for backend or server side stuff, whereas Modules can interact via the frontend or EE Control Panel. So an Extension captures a hook from another class, but can't capture a form submission or Ajax call from the frontend. Whereas a Module can't tap into a hook. But you can roll both an extension and a module into a single add-on (same name, shared folder, relevant separate files (ext.???, mod.???, etc).
Multiple hooks in a single extension:
Multiple Hooks, One Extension
A Module would be able to capture the events via ACTion URLs. Example install code (upd.module-name.php):
//### Create ACTion IDs for the relevant functions ###
$formActions = array(
"form_submission",
"start_booking",
"payment_notification"
);
foreach ($formActions as $method) {
$data = array(
'class' => $this->class,
'method' => $method
);
ee()->db->insert('actions', $data);
}//### End of foreach
In the above example, my module has public functions for:
- form_submission
- start_booking
- payment_notification
To render out the Action URL in your module (e.g. passing the ACTion URL to your frontend form or button click):
$actionID = ee()->functions->fetch_action_id(__CLASS__, 'form_submission');
Although in theory, if your events triggered other modules or core EE functionality, e.g. Freeform, member login, etc, then you could use other hooks to tap into the event. But from your question, I'm guessing you want custom events not related to existing EE functionality or other add-ons.