root / framework / branches / dev / fuseboxControllerMethod.cfc

Revision 421, 4.4 kB (checked in by scorfield, 2 years ago)

Tidied up how circuit-as-cfc is handled so that CFCs are actually instantiated and invoked
(rather than included like the former hack proof of concept).

Line 
1<!---
2Copyright 2006 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 output="false"
17                        hint="I represent a fuseaction as a method within a controller CFC or a controller within an implicit circuit.">
18
19        <cffunction name="init" returntype="any" access="public" output="false"
20                                hint="I am the constructor.">
21                <cfargument name="circuit" type="any" required="false"
22                                        hint="I am the circuit to which this fuseaction belongs. I am required but it's faster to specify that I am not required." />
23                <cfargument name="dottedPath" type="string" required="false"
24                                        hint="I am the dotted path to the CFC. I am required but it's faster to specify that I am not required." />
25                <cfargument name="name" type="any" required="false"
26                                        hint="I am the name of the fuseaction. I am required but it's faster to specify that I am not required." />
27                <cfargument name="fuseactionIsMethod" type="any" required="false"
28                                        hint="I indicate whether the fuseaction is method (or a controller). I am required but it's faster to specify that I am not required." />
29               
30                <cfset variables.circuit = arguments.circuit />
31                <cfset variables.dottedPath = arguments.dottedPath />
32                <cfset variables.name = arguments.name />
33                <cfset variables.fuseactionIsMethod = arguments.fuseactionIsMethod />
34               
35                <!--- implicit circuit fuseactions are public by default --->
36                <cfset this.access = "public" />
37                <cfset this.permissions = "" />
38               
39                <cfreturn this />
40               
41        </cffunction>
42       
43        <cffunction name="compile" returntype="void" access="public" output="false"
44                                hint="I compile this fuseaction.">
45                <cfargument name="writer" type="any" required="false"
46                                        hint="I am the writer object to which the compiled code should be written. I am required but it's faster to specify that I am not required." />
47       
48                <cfif variables.fuseactionIsMethod>
49                        <!--- TODO: if this throw Expression (Variable #uCase(getName())# is undefined.) then it was a missing fuseaction --->
50                        <cfset arguments.writer.println('<cfinvoke component="#variables.dottedPath#" method="#getName()#">') />
51                        <cfset arguments.writer.println('<cfinvokeargument name="myFusebox" value="##myFusebox##"/>') />
52                        <cfset arguments.writer.println('<cfinvokeargument name="event" value="##event##" />') />
53                        <cfset arguments.writer.println('</cfinvoke>') />
54                <cfelse>
55                        <!--- TODO: if this throw Expression (Variable #uCase(do)# is undefined.) then it was a missing/malformed fuseaction --->
56                        <cfset arguments.writer.println('<cfinvoke component="#variables.dottedPath#" method="do">') />
57                        <cfset arguments.writer.println('<cfinvokeargument name="myFusebox" value="##myFusebox##"/>') />
58                        <cfset arguments.writer.println('<cfinvokeargument name="event" value="##event##" />') />
59                        <cfset arguments.writer.println('</cfinvoke>') />
60                </cfif>
61
62        </cffunction>
63       
64        <cffunction name="getName" returntype="string" access="public" output="false"
65                                hint="I return the name of the fuseaction.">
66               
67                <cfreturn variables.name />
68               
69        </cffunction>
70
71        <cffunction name="getCircuit" returntype="any" access="public" output="false"
72                                hint="I return the enclosing circuit object.">
73       
74                <cfreturn variables.circuit />
75       
76        </cffunction>
77       
78        <cffunction name="getAccess" returntype="string" access="public" output="false"
79                                hint="I am a convenience method to return this fuseaction's access attribute value.">
80       
81                <cfreturn this.access />
82       
83        </cffunction>
84       
85        <cffunction name="getPermissions" returntype="string" access="public" output="false"
86                                hint="I return the aggregated permissions for this fuseaction.">
87       
88                <cfreturn this.permissions />
89               
90        </cffunction>
91       
92        <cffunction name="getCustomAttributes" returntype="struct" access="public" output="false"
93                                hint="I return the custom (namespace-qualified) attributes for this fuseaction tag.">
94                <cfargument name="ns" type="string" required="true"
95                                        hint="I am the namespace prefix whose attributes should be returned." />
96               
97                <cfreturn structNew() />
98
99        </cffunction>
100
101</cfcomponent>
Note: See TracBrowser for help on using the browser.