Skip to content
Randy Merrill edited this page Jan 28, 2011 · 8 revisions

How To Trigger Events

From Within Services

// Get the content plugin's domain event observer
observer = getPluginObserver('content', 'domain');

// Trigger the event on the observer passing along the needed information
observer.afterSave(transport, user, domain);

Everywhere Else

// Get the content plugin's domain event observer
observer = transport.theApplication.managers.plugin.getContent().getObserver().getDomain();

// Trigger the event on the observer passing along the needed information
observer.afterSave(transport, user, domain);

How To Handle Triggered Events

Event handlers in Algid plugins are organized based upon the plugin they are targeting and the observer that will be listening for the event.

For example, if you want to add an event handler for the afterSave event for the domain in the content plugin you would put the following in extend/content/events/evntDomain.cfc:

component extends="algid.inc.resource.base.event" {
	public void function afterSave( required struct transport, required component currUser, required component domain ) {
		// Do something with the after save event
		// Ex: Log the save
	}
}

What events get triggered are at the discretion of the plugin. See the individual plugin documentation for information on the events that are available.

Event Handler Precedence

Event handlers are executed in the order that they are added. Algid will load all events that follow the following pattern automatically in the order that the plugins appear in the application's plugins setting.

Event Handler Life Cycle

Event observers and handlers are created and stored as part application startup. If any changes are made, including new handlers, the application with have to be reinitialized to use the changed handlers.

Clone this wiki locally