|
27 | 27 | <cffunction name="loadBeansFromPath" access="public" output="false" returnType="void">
|
28 | 28 | <cfargument name="beanPath" type="string" required="true" hint="Absolute path to folder containing beans" />
|
29 | 29 | <cfargument name="resourcesPath" type="string" default="resources" />
|
| 30 | + <cfargument name="resourcesBasePath" type="string" default="" /> |
30 | 31 | <cfset var local = StructNew() />
|
31 | 32 | <!--- if the folder doesn't exist, do nothing --->
|
32 | 33 | <cfif not directoryExists(arguments.beanPath)>
|
33 | 34 | <cfreturn />
|
34 | 35 | </cfif>
|
35 | 36 | <!--- get list of beans to load --->
|
36 |
| - <cfdirectory action="list" directory="#arguments.beanPath#" filter="*.cfc" name="local.beanQuery" /> |
| 37 | + <cfdirectory action="list" directory="#arguments.beanPath#" filter="*.cfc" name="local.beanQuery" recurse="true" /> |
37 | 38 | <!--- cache all of the beans --->
|
38 | 39 | <cfset application._taffy.status.skippedResources = arrayNew(1) /> <!--- empty out the array on factory reloads --->
|
39 | 40 | <cfloop query="local.beanQuery">
|
40 |
| - <cfset local.beanName = left(local.beanQuery.name, len(local.beanQuery.name)-4) /><!--- drop the ".cfc" ---> |
| 41 | + <cfset local.beanName = filePathToBeanName(local.beanQuery.directory, local.beanquery.name, arguments.resourcesBasePath) /> |
| 42 | + <cfset local.beanPath = filePathToBeanPath(local.beanQuery.directory, local.beanquery.name, arguments.resourcesBasePath) /> |
41 | 43 | <cftry>
|
42 |
| - <cfset this.beans[local.beanName] = createObject("component", arguments.resourcesPath & "." & local.beanName) /> |
| 44 | + <cfset this.beans[local.beanName] = createObject("component", local.beanPath) /> |
43 | 45 | <cfcatch>
|
44 | 46 | <!--- skip cfc's with errors, but save info about them for display in the dashboard --->
|
45 | 47 | <cfset local.err = structNew() />
|
|
55 | 57 | <cfset _recurse_ResolveDependencies(local.b, local.beanMeta) />
|
56 | 58 | </cfloop>
|
57 | 59 | </cffunction>
|
| 60 | + |
| 61 | + <cffunction name="filePathToBeanPath" access="private"> |
| 62 | + <cfargument name="path" /> |
| 63 | + <cfargument name="filename" /> |
| 64 | + <cfargument name="basepath" /> |
| 65 | + <cfset var beanPath = |
| 66 | + "resources." |
| 67 | + & |
| 68 | + replace( |
| 69 | + replace(path, basepath, ""), |
| 70 | + "/", |
| 71 | + ".", |
| 72 | + "ALL" |
| 73 | + ) |
| 74 | + & |
| 75 | + "." |
| 76 | + & |
| 77 | + replace( |
| 78 | + filename, |
| 79 | + ".cfc", |
| 80 | + "" |
| 81 | + ) |
| 82 | + /> |
| 83 | + <cfif left(beanPath, 1) eq "."> |
| 84 | + <cfset beanPath = right(beanPath, len(beanPath)-1) /> |
| 85 | + </cfif> |
| 86 | + <cfreturn beanPath /> |
| 87 | + </cffunction> |
| 88 | + |
| 89 | + <cffunction name="filePathToBeanName" access="private"> |
| 90 | + <cfargument name="path" /> |
| 91 | + <cfargument name="filename" /> |
| 92 | + <cfargument name="basepath" /> |
| 93 | + <cfreturn |
| 94 | + replace( |
| 95 | + replace(path, basepath, ""), |
| 96 | + "/", |
| 97 | + "", |
| 98 | + "ALL" |
| 99 | + ) |
| 100 | + & replace( |
| 101 | + filename, |
| 102 | + ".cfc", |
| 103 | + "" |
| 104 | + ) |
| 105 | + /> |
| 106 | + </cffunction> |
| 107 | + |
58 | 108 | <cffunction name="_recurse_ResolveDependencies" access="private">
|
59 | 109 | <cfargument name="beanName" type="string" required="true" />
|
60 | 110 | <cfargument name="metaData" type="struct" required="true" />
|
|
0 commit comments