Guest User

Untitled

a guest
Jul 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. <cfcomponent>
  2.  
  3. <cfset $class = {}>
  4.  
  5. <cffunction name="init">
  6. <cfargument name="relativePath" type="string" default="" hint="the relative component path from the webroot">
  7. <cfset $class.container = []>
  8. <cfset $class.relativePath = arguments.relativePath>
  9. </cffunction>
  10.  
  11. <cffunction name="use" hint="Adds the new middleware at the bottom of the middleware stack.">
  12. </cffunction>
  13.  
  14. <cffunction name="insertBefore" hint="Adds the new middleware before the specified existing middleware in the middleware stack.">
  15. </cffunction>
  16.  
  17. <cffunction name="insertAfter" hint="Adds the new middleware after the specified existing middleware in the middleware stack.">
  18. </cffunction>
  19.  
  20. <cffunction name="swap" hint="Replaces the specified middleware with a new middleware">
  21. </cffunction>
  22.  
  23. <cffunction name="remove" hint="Removes a specified middleware">
  24. </cffunction>
  25.  
  26. <cffunction name="add" hint="Adds a middleware to the stack in a specified position">
  27. <cfargument name="middleware_name" required="true">
  28. <cfargument name="middleware_position" required="false" default="0">
  29. <cfset var loc = {}>
  30. <cfset loc.middleware_name = arguments.middleware_name>
  31. <cfset structDelete(arguments, "middleware")>
  32. <cfset loc.middleware_position = arguments.middleware_position>
  33. <cfset structDelete(arguments, "middleware")>
  34. <cfset loc.s = {name=loc.middleware_name, args=duplicate(arguments)}>
  35. <cfif loc.middleware_position eq 0>
  36. <cfset loc.middleware_position = ArrayLen(stack())>
  37. </cfif>
  38. <cfset ArrayInsertAt($class.container, loc.middleware_position)>
  39. </cffunction>
  40.  
  41. <cffunction name="position" hint="Returns the position of the specified middleware in the stack">
  42. <cfargument name="middleware_name">
  43. <cfset var loc = {}>
  44. <cfset loc.stack = stack()>
  45. <cfset loc.size = ArrayLen(loc.stack)>
  46. <cfloop from="1" to="#loc.size#">
  47. </cffunction>
  48.  
  49. <cffunction name="clear" hint="Clears the middleware stack">
  50. <cfset ArrayClear($class.container)>
  51. </cffunction>
  52.  
  53. <cffunction name="stack" hint="Returns the middleware stack.">
  54. <cfreturn $class.container>
  55. </cffunction>
  56.  
  57. </cfcomponent>
Add Comment
Please, Sign In to add comment