For the complete documentation index, see llms.txt. This page is also available as Markdown.

How do they work?

Interceptors are singleton classes that extend coldbox.system.Interceptor, implement configure(), and define methods for the events they listen to.

Interceptors are classes that extend the ColdBox Interceptor class (coldbox.system.Interceptor), implement a configuration method called configure(), and then contain methods for the events it will listen for. All interceptors are treated as singletons in your application, so make sure they are thread safe and var scoped.

/**
* My Interceptor
*/
class extends="coldbox.system.Interceptor"{

    function configure(){}

    function preProcess( event, interceptData, buffer, rc, prc ){}
}
/**
* My Interceptor
*/
component extends="coldbox.system.Interceptor"{

    function configure(){}

    function preProcess( event, interceptData, buffer, rc, prc ){}
}

Info You can also remove the inheritance from the class (preferred method) and WireBox will extend the coldbox.system.Interceptor for you using Virtual Inheritance.

You can use CommandBox to create interceptors as well:

Registration

Interceptors can be registered in your Coldbox.bx (or .cfc for CFML) configuration file using the interceptors struct, or they can be registered manually via the system's interceptor service.

In ColdBox.bx (or .cfc for CFML):

Registered manually:

The configure() Method

The interceptor has one important method that you can use for configuration called configure(). This method will be called right after the interceptor gets created and injected with your interceptor properties.

Info These properties are local to the interceptor only!

As you can see on the diagram, the interceptor class is part of the ColdBox framework super type family, and thus inheriting the functionality of the framework.

Last updated

Was this helpful?