Controller
setFilterChain()
Signature
Section titled “Signature”setFilterChain() — returns void
Available in: controller
Category: Configuration Functions
Description
Section titled “Description”Use this function if you need a more low level way of setting the entire filter chain for a controller.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
chain | array | yes | — | An array of structs, each of which represent an argumentCollection that get passed to the filters function. This should represent the entire filter chain that you want to use for this controller. |
Examples
Section titled “Examples”// 1. Set the entire filter chain directly using an array of structs
setFilterChain([
{through="restrictAccess"},
{through="isLoggedIn, checkIPAddress", except="home, login"},
{type="after", through="logConversion", only="thankYou"}
]);
// 2. Replace an inherited filter chain in a child controller by starting fresh
// In app/controllers/Admin.cfc config():
parentChain = filterChain();
// Modify parentChain as needed, then reassign it wholesale
setFilterChain([
{through="requireAdmin"},
{through="loadCurrentUser", except="login"},
{type="after", through="auditAction"}
]);
// 3. Conditionally swap the filter chain based on application mode
if (get("environment") == "testing") {
setFilterChain([
{through="stubAuthentication"}
]);
} else {
setFilterChain([
{through="requireSSL"},
{through="authenticate"},
{type="after", through="trackPageView"}
]);
}