Skip to content

Instantly share code, notes, and snippets.

@rip747
rip747 / gist:2853902
Created June 1, 2012 17:38
implementing a CFWheels service layer
<!--- add the following to the events/onapplicationstart.cfm --->
<cffunction name="initServices" returntype="void" hint="I initialize the services objects for this app">
<cfset var loc = {}>
<cfset application.$_ServiceObjects = {}>
<cfdirectory action="list" directory="#expandPath('services')#" name="loc.services"/>
<cfloop query="loc.services">
<cfset application.$_ServiceObjects[ListFirst(name, '.')] = createObject("component", "services.#ListFirst(name, '.')#").init()>
</cfloop>
</cffunction>
<cfset initServices()>