Plugins and Events
- Overview: Plugins and Events
- Plugin Development
- Plugin Cookbook (work in process)
- Examples
Events and plugin architecture
With OntoWiki 0.8.5 we add a plugin architecture which can be used to integrate your own functionality to OntoWiki and Erfurt through plugins. Those plugins can be deployed by providing classes and methods as event handlers to OntoWiki and Erfurt events. An event dispatcher is used to publish those events.
Plugins
Installation
Plugin integration to OntoWiki is easy: copy all files of a plugin package and the associated configuration file (config.ini) into one own folder in OntoWiki's plugin directory and switch the plugin on (for now in config.ini). You can specify OntoWiki's plugin directory in OntoWiki's config.ini:
;--------------------------------------; ; The path to OntoWiki plugin folder ; ;--------------------------------------; plugins.ontowiki = plugins/; relative path to OntoWiki root directory
Add more different folders (this feature is planned, it's not working yet):
plugins.name1 = pluginfolder2/ plugins.name2 = ../../plugins/outside/ontowiki/app/
Choose your own alphanumerical names but please do not use plugins.erfurt in config.ini. All added paths are crawled for plugins' for the config.ini configuration file.
Plugin development
Plugins can be used to add new functionality to OntoWiki or its user interface without the necessary to hack the OntoWiki core code. Additionally you can provide new libraries and their interfaces through plugins. To integrate plugins automatically we provide events which can be subscribed by your plugin's methods as event handlers. Please read further:
- How to develop an OntoWiki plugin
- Plugin Cookbook (work in process)
Events
The event dispatcher has been built in with OntoWiki 0.8.5 and it can be used to publish events (trigger events) and to subscribe event handlers (announcing mthods from plugin classes as event handlers) to those events. We distinguish between three groups of events:
- Zend events: those events are triggered automatically based on Zend event methods
- Core events: contains events which are triggered in the core code on decision by OntoWiki / Erfurt developers
- Third party events: events triggered by plugins
Technically there are no differences between the events of each group.
Zend events
In OntoWiki we trigger
Zend event methods automatically, names are:
- ZendRouteStartup
- ZendRouteShutdown
- ZendDispatchLoopStartup
- ZendPreDispatch
- ZendPostDispatch
- ZendDispatchLoopShutdown
Additionally we have those events prefixed by the current route request. The prefix is composed of the module name, controller name and the action name (all parts in lowercase letters) of the requested route. OntoWiki has only one default module, so the prefix is ending up in default_controllername_actionname_. For example while the request of
http://demo.ontowiki.net/wiki/registerNew/ the event default_wiki_registernew_ZendPostDispatch is published beside the ZendPostDispatch event. The prefixed Zend event are triggered right after the usual Zend event has been published.
Core events
Core events are added to the core code of OntoWiki and Erfurt. We will develop a convention for trigger names which will be documented here together with the attribute passed to the plugin's method.
- RDFSModel_add_pre with data: associative array with key statement
- RDFSModel_add_post with data: associative array with keys statement, success
- RDFSModel_remove_pre with data: associative array with key statement
- RDFSModel_remove_post with data: associative array with keys statement, success
Third party events
Also plugins and other third party code can trigger events. Please use the private $_erfurtApp object in your methods:
$eventDispatcher = $this->_erfurtApp->getEventDispatcher();
$bool = $eventDispatcher->trigger('name_of_event',&$passed_var);
Please pass references to the trigger (objects are references!).
Information
Last Modification:
2008-07-22 20:20:21 by Michael Haschke