Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfcomponent>
- <cfset $class = {}>
- <cffunction name="init">
- <cfargument name="relativePath" type="string" default="" hint="the relative component path from the webroot">
- <cfset $class.container = []>
- <cfset $class.relativePath = arguments.relativePath>
- </cffunction>
- <cffunction name="use" hint="Adds the new middleware at the bottom of the middleware stack.">
- </cffunction>
- <cffunction name="insertBefore" hint="Adds the new middleware before the specified existing middleware in the middleware stack.">
- </cffunction>
- <cffunction name="insertAfter" hint="Adds the new middleware after the specified existing middleware in the middleware stack.">
- </cffunction>
- <cffunction name="swap" hint="Replaces the specified middleware with a new middleware">
- </cffunction>
- <cffunction name="remove" hint="Removes a specified middleware">
- </cffunction>
- <cffunction name="add" hint="Adds a middleware to the stack in a specified position">
- <cfargument name="middleware_name" required="true">
- <cfargument name="middleware_position" required="false" default="0">
- <cfset var loc = {}>
- <cfset loc.middleware_name = arguments.middleware_name>
- <cfset structDelete(arguments, "middleware")>
- <cfset loc.middleware_position = arguments.middleware_position>
- <cfset structDelete(arguments, "middleware")>
- <cfset loc.s = {name=loc.middleware_name, args=duplicate(arguments)}>
- <cfif loc.middleware_position eq 0>
- <cfset loc.middleware_position = ArrayLen(stack())>
- </cfif>
- <cfset ArrayInsertAt($class.container, loc.middleware_position)>
- </cffunction>
- <cffunction name="position" hint="Returns the position of the specified middleware in the stack">
- <cfargument name="middleware_name">
- <cfset var loc = {}>
- <cfset loc.stack = stack()>
- <cfset loc.size = ArrayLen(loc.stack)>
- <cfloop from="1" to="#loc.size#">
- </cffunction>
- <cffunction name="clear" hint="Clears the middleware stack">
- <cfset ArrayClear($class.container)>
- </cffunction>
- <cffunction name="stack" hint="Returns the middleware stack.">
- <cfreturn $class.container>
- </cffunction>
- </cfcomponent>
Add Comment
Please, Sign In to add comment