Skip to content

Plugins: Life Cycle

Randy Merrill edited this page Jan 28, 2011 · 1 revision

Application Hooks

Plugins are able to hook into some of the core application life cycle features using the config/configure.cfc component.

The hooks are executed in the order of the application's plugins setting.

canReinitialize(theApplication, theSession, theForm)

When a request is made to reinitialize the application the plugins are consulted with the available information to determine if the given request has the right to reinitialize the application.

If any of the plugins returns false the application will not be reinitialized.

onApplicationEnd(theApplication)

Occurs when the CFML engine naturally shuts down and just before the application is reinitialized.

onApplicationStart(theApplication)

Occurs when the CFML engine starts serving requests for the application and when the application is reinitialized.

onRequestEnd(theApplication, theSession, theRequest)

Occurs at the end of a request.

onRequestStart(theApplication, theSession, theRequest, theUrl, theForm, targetPage)

Occurs at the start of a request.

onSessionEnd(theApplication, theSession)

Occurs at the end of a session.

onSessionStart(theApplication, theSession)

Occurs at the start of a session.

update(plugin, installedVersion)

When the application is being initialized or reinitialized it reads in the settings and information for each of the plugins. The update function is used to update the state of the environment to match what the plugin is expecting to run.

For example, when using a database any database commands that would setup or alter the environment should be run here as needed.

As another example, creating a directory to contain non-webroot based files or images used in the plugin.

Clone this wiki locally