root / framework / trunk / corefiles / fuseboxImplicitCircuit.cfc

Revision 755, 5.2 kB (checked in by a.haskell@…, 4 months ago)

Added explicit No XML and alias path finding for xml circuits. I need to make tickets for this stuff....and get mylyn working.

Line 
1<!---
2Copyright 2006-2007 TeraTech, Inc. http://teratech.com/
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15--->
16<cfcomponent hint="I represent an implicit circuit." output="false" extends="fuseboxNoXmlCircuit">
17       
18        <cffunction name="init" returntype="any" access="public" output="false"
19                                hint="I am the constructor.">
20                <cfargument name="fbApp" type="fuseboxApplication" required="true"
21                                        hint="I am the fusebox application object." />
22                <cfargument name="alias" type="string" required="true"
23                                        hint="I am the circuit alias." />
24                <cfargument name="myFusebox" type="myFusebox" required="true"
25                                        hint="I am the myFusebox data structure." />
26                <cfreturn SUPER.init(fbApp,alias,myFusebox,"")>
27        </cffunction>
28       
29        <cffunction name="reload" returntype="any" access="public" output="false"
30                                hint="I reload the circuit file and build the in-memory structures from it.">
31                <cfargument name="myFusebox" type="myFusebox" required="true"
32                                        hint="I am the myFusebox data structure." />
33               
34                <cfset var found = false />
35                <cfset var path = "" />
36               
37                <cfset this.access = "public" />
38                <cfset variables.fuseactionIsMethod = false />
39               
40                <!---
41                        in order of preference, we want to find:
42                        1. {MVC}/{alias}.cfc
43                                - this implies fuseactions are methods
44                        2. {MVC}/{alias}/
45                                - we can look for {fuseaction}.xml or {fuseaction}.cfm later
46                        3. {alias}/
47                                - we can look for {fuseaction}.xml or {fuseaction}.cfm later
48                --->
49
50                <cfloop index="path" list="controller/,model/,view/">
51
52                        <cfset variables.originalPath = path />
53                        <cfset variables.fullPath = variables.appPath & variables.originalPath />
54                        <cfset variables.relativePath = variables.fuseboxApplication.relativePath(variables.appPath,variables.fullPath) />
55       
56                        <!--- if the CFC actually exists, see if we can figure out if it exists in a sensible place --->
57                        <cfif fileExists(variables.fullPath & getAlias() & ".cfc")>
58                                <cfset variables.dottedPath = variables.fuseboxApplication.locateCfc(variables.fullPath & getAlias() & ".cfc") />
59                                <cfif variables.dottedPath is not "">
60                                        <cfset found = true />
61                                        <cfset variables.fuseactionIsMethod = true />
62                                        <cfif variables.fuseboxApplication.debug>
63                                                <cfset arguments.myFusebox.trace("Compiler","Implicit component-as-circuit #variables.originalPath##getAlias()#.cfc identified") />
64                                        </cfif>
65                                        <cfbreak />
66                                </cfif>
67                        </cfif>
68
69                        <!--- first time through, access is public for controller - should change to internal for model / view circuits --->
70                        <cfset this.access = "internal" />
71                       
72                </cfloop>
73
74                <cfif not found>
75                        <!--- no CFCs so look for an MVC directory --->
76                        <cfset this.access = "public" />
77
78                        <cfloop index="path" list="controller/,model/,view/">
79       
80                                <cfset variables.originalPath = path & getAlias() & "/" />
81                                <cfset variables.fullPath = variables.appPath & variables.originalPath />
82                                <cfset variables.relativePath = variables.fuseboxApplication.relativePath(variables.appPath,variables.fullPath) />
83       
84                                <!--- MVC circuit directory? --->
85                                <cfif directoryExists(variables.fullPath)>
86                                        <!--- looks like we have a candidate --->
87                                        <cfset found = true />
88                                        <cfif variables.fuseboxApplication.debug>
89                                                <cfset arguments.myFusebox.trace("Compiler","Implicit circuit #variables.originalPath# identified") />
90                                        </cfif>
91                                        <cfbreak />
92                                </cfif>
93                               
94                                <!--- first time through, access is public for controller - should change to internal for model / view circuits --->
95                                <cfset this.access = "internal" />
96                               
97                        </cfloop>
98
99                </cfif>                                 
100               
101                <cfif not found>
102                        <!--- no MVC, what about just a directory? --->
103                        <cfset this.access = "public" />
104                        <cfset variables.originalPath = getAlias() & "/" />
105                        <cfset variables.fullPath = variables.appPath & variables.originalPath />
106                        <cfset variables.relativePath = variables.fuseboxApplication.relativePath(variables.appPath,variables.fullPath) />
107
108                        <cfif directoryExists(variables.fullPath)>
109
110                                <!--- ok, the directory exists --->
111                                <cfif variables.fuseboxApplication.debug>
112                                        <cfset arguments.myFusebox.trace("Compiler","Implicit circuit #getAlias()# identified") />
113                                </cfif>
114
115                        <cfelse>
116
117                                <cfthrow type="fusebox.undefinedCircuit"
118                                                message="undefined Circuit"
119                                                detail="You specified a Circuit of #getAlias()# which is not defined." />
120
121                        </cfif>
122
123                </cfif>
124               
125                <!--- we don't know what fuseactions an implicit circuit has --->
126                <cfset this.fuseactions = structNew() />
127                <cfset this.parent = "" />
128                <cfset this.permissions = "" />
129                <cfset this.path = variables.relativePath />
130                <cfset this.rootPath = variables.fuseboxApplication.relativePath(variables.fullPath,variables.appPath) />
131                <cfset this.timestamp = now() />
132
133        </cffunction>
134       
135</cfcomponent>
Note: See TracBrowser for help on using the browser.