Skip to content
12345j edited this page Oct 8, 2011 · 3 revisions

Abstract

Events are methods of modifying/receiving data. Events are similar to drupals hook system. When certain actions are preformed (like editing a page), that data is then made available to be modified or recieved by any and all third party events that are registered.

Code

API

Code Examples

Events::registerEvent('page_edit','extend/hello_world.php','helloWorld','hello_world_extension', 0)

With this we let writr know that there is a new function that it needs to run when page_edit is fired. extend/hello_world.php is the path to the file that we want to use to modify the data, and helloWord is the function that we want to call in the given file. hello_world_extension lets us associate this event with an extension so that we can uninstall it correctly. The 0 lets you know that this even only wants to get the data, but not modify it.

Events::fire('page_edit', array($content,$description,$file))

We're running the event page_edit now. This will run the helloWorld function in extend/hello_world.php that we just installed. The second argument is the data that you want to pass on to the helloWorld function. This will be returned in the same format.

Events::uninstallExtEvent('page_edit','hello_world_extension')

now we're uninstalling the event we just installed- delete all page_edit events installed from hello_world_extension.

Clone this wiki locally