Another excerpt from “Por que CF?” by Pedro Claudio.
To continue the “play” initiated by Ricardo Parente, but now using the Application.cfc, I show here 5 non-documented methods that can entertain us for hours.
To start playing, create a component and name it Father.cfc, with the following content:<cfcomponent>
Create an Application.cfc in the same folder, extending the previous component.
<cffunction name="ProxyScope">
<!--- ColdFusion 8 --->
<cfreturn StructCopy(variables) >
</cffunction>
</cfcomponent><cfcomponent extends="Pai">
Now it’s only playing.
<cfset this.name="scope_app" >
<cfset Variables.pcsilva = "Pedro Claudio" >
</cfcomponent>
Method getEventInvoker returns the entire class responsible for Application.cfc:<cfdump var="#application.getEventInvoker()#">
getApplicationSettings returns all Application’s properties (similar to the attributes of cfapplication) and plus the methods in the Application.cfc:<cfdump var="#application.getApplicationSettings()#">
Identical to the method getApplicationSettings:<cfdump var="#application.getEventInvoker().getThisScope()#">
getEventInvoker().invoke executes a method from Application.cfc, here I’ll give you an example with a method that returns all the Application.cfc scopes, including the Variables:<cfdump var="#application.getEventInvoker().invoke('ProxyScope',ArrayNew(1))#">
And just to be certain where this method ProxyScope is being executed:<cfdump var="#application.getEventInvoker().getThisScope().ProxyScope.getPagePath()#">