Table of Contents
In addition to the API for logging in, GenieGate supports something called plugins. These plugins are used when you need to react to one or more events taking place within GenieGate.
An example would be a plugin which creates a set of directories whenever a person is added to an "upload" group.
The process of creating a plugin involves inheriting from GenieGate_Api_Plugin
and implementing only the methods you are interested in.
Note that no constructor will be invoked automatically, you have to do that during the initial require stage.
Example 4.1. Installing a plugin
<?php
/**
* We're called with an object that supports an addListener() method. (a controller
* most likely)
*
* So, the first thing we do is create an instance of ourselves and
* tell the caller we're interested in hearing events. Like so:
*/
$this->addListener(new MyPlugin());
/**
* Next come the events we're interested in.
*
* Notice that we extend GenieGate_Api_Plugin, this gives us all
* the methods here and shields us from a situation where future
* versions of GenieGate (in the 1.n.n series) add additional
* methods.
*
*/
class MyPlugin extends GenieGate_Api_Plugin {
// We're interest in hearing about when new users are created.
public function setupUser(&$ua,&$fields,$confirm_id){
// Do stuff here...
}
}
?>
The logger plugin GenieGate_Api_Plugin_Logger is an excellent
starting place for writing a plugin. It is used as a reference implementation
and can be examined as a guide to writing your own plugins.
The Logger plugin's only function is to listen for events and then send log those events to a file. You can then examine the file to determine which events are being called (and in turn, which methods you will need to override for your plugin)