Creating Listeners Key to understanding Mach-II is discovering how to access variables passed in an event. For Fusebox developers the technique will feel similar to referencing form variables in the attributes scope: the framework does the conversion of form and url variables to properties of a Mach-II event (Event). In our demo we post a form and process the variables with a Mach-II listener class. This class is a regular PHP class that extends MachII.framework.Listener:
These variables are accessed by the listener class by calling Event like this:
Listener classes are called by the framework using the mappings defined in the type attribute of a <listener> node (fig. 8). A method is defined in the event handler and then passed to the listener. Mach-II locates the listener class in its directory and calls the desired method. Finally, the listener receives the Event object and processes the request.
blog comments powered by Disqus |