Skip to content

Commit 46702da

Browse files
author
Adam Tuttle
committed
#48 well that wasn't so hard
1 parent c61d59e commit 46702da

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

core/api.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
<cfif directoryExists(_taffyRequest.resourcePath)>
318318
<!--- setup internal bean factory --->
319319
<cfset application._taffy.factory = createObject("component", "taffy.core.factory").init() />
320-
<cfset application._taffy.factory.loadBeansFromPath(_taffyRequest.resourcePath, guessResourcesCFCPath()) />
320+
<cfset application._taffy.factory.loadBeansFromPath(_taffyRequest.resourcePath, guessResourcesCFCPath(), guessResourcesFullPath()) />
321321
<cfset application._taffy.beanList = application._taffy.factory.getBeanList() />
322322
<cfset cacheBeanMetaData(application._taffy.factory, application._taffy.beanList) />
323323
<cfset application._taffy.status.internalBeanFactoryUsed = true />

core/factory.cfc

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,21 @@
2727
<cffunction name="loadBeansFromPath" access="public" output="false" returnType="void">
2828
<cfargument name="beanPath" type="string" required="true" hint="Absolute path to folder containing beans" />
2929
<cfargument name="resourcesPath" type="string" default="resources" />
30+
<cfargument name="resourcesBasePath" type="string" default="" />
3031
<cfset var local = StructNew() />
3132
<!--- if the folder doesn't exist, do nothing --->
3233
<cfif not directoryExists(arguments.beanPath)>
3334
<cfreturn />
3435
</cfif>
3536
<!--- 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" />
3738
<!--- cache all of the beans --->
3839
<cfset application._taffy.status.skippedResources = arrayNew(1) /> <!--- empty out the array on factory reloads --->
3940
<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) />
4143
<cftry>
42-
<cfset this.beans[local.beanName] = createObject("component", arguments.resourcesPath & "." & local.beanName) />
44+
<cfset this.beans[local.beanName] = createObject("component", local.beanPath) />
4345
<cfcatch>
4446
<!--- skip cfc's with errors, but save info about them for display in the dashboard --->
4547
<cfset local.err = structNew() />
@@ -55,6 +57,54 @@
5557
<cfset _recurse_ResolveDependencies(local.b, local.beanMeta) />
5658
</cfloop>
5759
</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+
58108
<cffunction name="_recurse_ResolveDependencies" access="private">
59109
<cfargument name="beanName" type="string" required="true" />
60110
<cfargument name="metaData" type="struct" required="true" />
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)