Skip to content

Controller

setFilterChain()

setFilterChain() — returns void

Available in: controller Category: Configuration Functions

Use this function if you need a more low level way of setting the entire filter chain for a controller.

NameTypeRequiredDefaultDescription
chainarrayyes—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.
// 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"}
	]);
}