Handlers
The Mason Framework have to main code types. Modules are called to complete a template placeholder, and handlers are called to modify a data structure. If modules always get the same type of information and are always expected to do the same kind of thing, with handlers everything is more fuzzy.Each ($zone. $zonetype) combination do their own job and, as handlers are expected to process data structures that are specific, what they get and what they are expected to do changes a lot.
There is a list of all core hooks, with descriptions and parameters, but keep reading if you want to know more than just which they are.
How it works?
The Mason Framework API provides a method handle(...) that allow you to call an handler at anytime. That method will take as parameter the zone and zonetype for the handler to call, as well as any parameters that should be given to the handler. As an example:
$mf->handle(zone=>'abc', zonetype=>'def',
args={
arg1 => 'abc',
arg2 => 'def'
});
Will be given to the handler as:
<%args> $zone => 'abc' $zonetype => 'def' $arg1 => 'abc' $arg2 => 'def' $mf $args </%args>
$mf will always be the MFWork object, and $args the configs present in the Parameters field in the Handlers configuration page.
Filters, unlike modules, are expected to return values. Those values should be one of:
- OK() - EVerything OK with the handler. It did what it was intented to do.
- ERROR('error message') - There was an error. This must be returned only when a real error happens, for instance, an handler called without a mandatory arg for its handling type (is it in the incorrect hook?).
- DECLINED('decline message') - This handler can't process what it got, but it was expecting to be called with it.
This return methods are called in the MFWork/Handler module.
This are the basics... later, if needed, I will get back here to extend this page. For now, go to the core handlers and hooks list.