| 1 | <!--- |
|---|
| 2 | Copyright 2006-2007 TeraTech, Inc. http://teratech.com/ |
|---|
| 3 | |
|---|
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
|---|
| 5 | you may not use this file except in compliance with the License. |
|---|
| 6 | You may obtain a copy of the License at |
|---|
| 7 | |
|---|
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 9 | |
|---|
| 10 | Unless required by applicable law or agreed to in writing, software |
|---|
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 13 | See the License for the specific language governing permissions and |
|---|
| 14 | limitations 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 | <cfset var uniqueName = "__fuseboxCircuitCfc_" & replace(replace(variables.dottedPath,"-","$","all"),".","_","all") /> |
|---|
| 49 | |
|---|
| 50 | <cfset arguments.writer.println('<cfparam name="#uniqueName#" default="##createObject(''component'',''#variables.dottedPath#'')##" />') /> |
|---|
| 51 | |
|---|
| 52 | <!--- |
|---|
| 53 | TODO: technically it is not correct to call prefuseaction() / postfuseaction() for a do() method since that |
|---|
| 54 | represents just a fuseaction in a circuit and really we should check for prefuseaction.cfm and prefuseaction.cfc (do) |
|---|
| 55 | instead... |
|---|
| 56 | ---> |
|---|
| 57 | <cfset arguments.writer.println('<cfif structKeyExists(#uniqueName#,"prefuseaction") and isCustomFunction(#uniqueName#.prefuseaction)>') /> |
|---|
| 58 | <cfset arguments.writer.println('<cfset #uniqueName#.prefuseaction(myFusebox=myFusebox,event=event) />') /> |
|---|
| 59 | <cfset arguments.writer.println('</cfif>') /> |
|---|
| 60 | |
|---|
| 61 | <cfif variables.fuseactionIsMethod> |
|---|
| 62 | <cfset arguments.writer.println('<cfif structKeyExists(#uniqueName#,"#getName()#") and isCustomFunction(#uniqueName#.#getName()#)>') /> |
|---|
| 63 | <cfset arguments.writer.println('<cfset return_#getCircuit().getAlias()#_#getName()# = #uniqueName#.#getName()#(myFusebox=myFusebox,event=event) />') /> |
|---|
| 64 | <cfset arguments.writer.println('<cfelse><' & |
|---|
| 65 | 'cfthrow type="fusebox.undefinedFuseaction" ' & |
|---|
| 66 | 'message="undefined Fuseaction" ' & |
|---|
| 67 | 'detail="You specified a Fuseaction of #getName()# which is not defined in Circuit #getCircuit().getAlias()#.">') /> |
|---|
| 68 | <cfset arguments.writer.println('</cfif>') /> |
|---|
| 69 | <cfelse> |
|---|
| 70 | <cfset arguments.writer.println('<cfif structKeyExists(#uniqueName#,"do") and isCustomFunction(#uniqueName#.do)>') /> |
|---|
| 71 | <cfset arguments.writer.println('<cfset return_#getCircuit().getAlias()#_#getName()# = #uniqueName#.do(myFusebox=myFusebox,event=event) />') /> |
|---|
| 72 | <cfset arguments.writer.println('<cfelse><' & |
|---|
| 73 | 'cfthrow type="fusebox.undefinedFuseaction" ' & |
|---|
| 74 | 'message="undefined Fuseaction" ' & |
|---|
| 75 | 'detail="You specified a Fuseaction of #getName()# which is not defined in Circuit #getCircuit().getAlias()#.">') /> |
|---|
| 76 | <cfset arguments.writer.println('</cfif>') /> |
|---|
| 77 | </cfif> |
|---|
| 78 | |
|---|
| 79 | <cfset arguments.writer.println('<cfif structKeyExists(#uniqueName#,"postfuseaction") and isCustomFunction(#uniqueName#.postfuseaction)>') /> |
|---|
| 80 | <cfset arguments.writer.println('<cfset #uniqueName#.postfuseaction(myFusebox=myFusebox,event=event) />') /> |
|---|
| 81 | <cfset arguments.writer.println('</cfif>') /> |
|---|
| 82 | |
|---|
| 83 | </cffunction> |
|---|
| 84 | |
|---|
| 85 | <cffunction name="getName" returntype="string" access="public" output="false" |
|---|
| 86 | hint="I return the name of the fuseaction."> |
|---|
| 87 | |
|---|
| 88 | <cfreturn variables.name /> |
|---|
| 89 | |
|---|
| 90 | </cffunction> |
|---|
| 91 | |
|---|
| 92 | <cffunction name="getCircuit" returntype="any" access="public" output="false" |
|---|
| 93 | hint="I return the enclosing circuit object."> |
|---|
| 94 | |
|---|
| 95 | <cfreturn variables.circuit /> |
|---|
| 96 | |
|---|
| 97 | </cffunction> |
|---|
| 98 | |
|---|
| 99 | <cffunction name="getAccess" returntype="string" access="public" output="false" |
|---|
| 100 | hint="I am a convenience method to return this fuseaction's access attribute value."> |
|---|
| 101 | |
|---|
| 102 | <cfreturn this.access /> |
|---|
| 103 | |
|---|
| 104 | </cffunction> |
|---|
| 105 | |
|---|
| 106 | <cffunction name="getPermissions" returntype="string" access="public" output="false" |
|---|
| 107 | hint="I return the aggregated permissions for this fuseaction."> |
|---|
| 108 | |
|---|
| 109 | <cfreturn this.permissions /> |
|---|
| 110 | |
|---|
| 111 | </cffunction> |
|---|
| 112 | |
|---|
| 113 | <cffunction name="getCustomAttributes" returntype="struct" access="public" output="false" |
|---|
| 114 | hint="I return the custom (namespace-qualified) attributes for this fuseaction tag."> |
|---|
| 115 | <cfargument name="ns" type="string" required="true" |
|---|
| 116 | hint="I am the namespace prefix whose attributes should be returned." /> |
|---|
| 117 | |
|---|
| 118 | <cfreturn structNew() /> |
|---|
| 119 | |
|---|
| 120 | </cffunction> |
|---|
| 121 | |
|---|
| 122 | </cfcomponent> |
|---|