Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ideas:eventapi [2010/03/09 20:35] (current)
Mark created
Line 1: Line 1:
 +====== Plugin API Replacement ======
 +
 +The current plugin API is functional but it requires that plugins have too much knowledge about other plugins to take advantage of services offered.  Having a class based plugin API based on event publishing / subscription would be a more desirable long term platform for plugin development / interaction.
 +
 +===== Design Ideas =====
 +
 +The event system could consist of two classes, the EventMgr and the Event. The EventMgr is where events are registered, subscribed to and fired. The Event class is an object passed to the observer when the event occurs. There could be four (4) types of events:  Notice, Request, Allow and Deny.
 +  * A Notice event gives notice that something has occurred. No return is expected from these events.
 +  * A Request event is expecting data. The plugin_useroptions_$plugin callback is an example of a request event.
 +  * An Allow request asks all the observers if an action is allowed. If any observer allows the action, it is allowed.
 +  * A Deny request is the same as the allow request except it asks if the action should be denied.
 +
 +The Allow and Deny requests can be set to strict or lazy evaluation. With lazy evaluation as soon as one observer returns true, none of the other observers are called. Strict evaluation will call all observers even if the result has been finalized.
 +
 +Events exist in a two-level name space. There is a domain and a name within the domain. Observers can subscribe to individual named events or all events on the domain. To do so, an observer calls the addObserver method on the EventMgr object. 
 +
 +This function has 4 parameters:
 +
 +  * An identifier uniquely identifying the observer
 +  * A valid PHP callback
 +  * The Domain name
 +  * And an optional Event Name.
 +
 +Event types could be stored in the database. The event_type table might list all the valid events registered with the system. This is where information about the event's type (notice, request, allow or deny) and evaluation structure is stored. Subscriptions are made every time the system loads to keep additional DB requests at a minimum to ensure scalability and performance is maintained.
 +
 +
 +
 +===== Skills Needed =====
 +
 +A strong understanding of PHP and object oriented programming will be required.  A good understanding of the existing [[glfusion:development:api:plg|glFusion Plugin API]] will be helpful.
 +
 +===== Difficulty =====
 +
 +
 +Difficult
 +
 +Implementing a new Plugin API will touch every aspect of glFusion and require a significant effort to ensure compatibility and proper integration.
 +
 +===== Licensing =====
 +
 +
 +All code must be created using the GNU General Public License
  
ideas/eventapi.txt · Last modified: 2010/03/09 20:35 by Mark
 
Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License 1.3