| 1 | <!----------------------------------------------------------------------- |
|---|
| 2 | ******************************************************************************** |
|---|
| 3 | Copyright 2005-2008 ColdBox Framework by Luis Majano and Ortus Solutions, Corp |
|---|
| 4 | www.coldboxframework.com | www.luismajano.com | www.ortussolutions.com |
|---|
| 5 | ******************************************************************************** |
|---|
| 6 | |
|---|
| 7 | Author : Luis Majano |
|---|
| 8 | Date : September 23, 2005 |
|---|
| 9 | Description : |
|---|
| 10 | This is a cfc that all event handlers should extend |
|---|
| 11 | |
|---|
| 12 | Modification History: |
|---|
| 13 | 01/12/2006 - Added fix for whitespace management. |
|---|
| 14 | 06/08/2006 - Updated for coldbox |
|---|
| 15 | 07/29/2006 - Datasource support via getdatsource() |
|---|
| 16 | |
|---|
| 17 | -----------------------------------------------------------------------> |
|---|
| 18 | <cfcomponent name="eventhandler" |
|---|
| 19 | hint="This is the event handler base cfc." |
|---|
| 20 | output="false" |
|---|
| 21 | extends="frameworkSupertype"> |
|---|
| 22 | |
|---|
| 23 | <!------------------------------------------- CONSTRUCTOR -------------------------------------------> |
|---|
| 24 | |
|---|
| 25 | <cffunction name="init" access="public" returntype="any" output="false" hint="The event handler controller"> |
|---|
| 26 | <cfargument name="controller" type="any" required="true" hint="coldbox.system.controller"> |
|---|
| 27 | <cfscript> |
|---|
| 28 | /* Register Controller */ |
|---|
| 29 | setController(arguments.controller); |
|---|
| 30 | |
|---|
| 31 | /* Inject user dependencies. */ |
|---|
| 32 | includeUDF(getController().getSetting("UDFLibraryFile")); |
|---|
| 33 | |
|---|
| 34 | /* Return Instance */ |
|---|
| 35 | return this; |
|---|
| 36 | </cfscript> |
|---|
| 37 | </cffunction> |
|---|
| 38 | |
|---|
| 39 | <!------------------------------------------- PUBLIC -------------------------------------------> |
|---|
| 40 | |
|---|
| 41 | <!--- Invoker Mixin ---> |
|---|
| 42 | <cffunction name="_privateInvoker" hint="calls private/packaged/public methods. Used internally by coldbox to execute private events" access="public" returntype="any" output="false"> |
|---|
| 43 | <!--- ************************************************************* ---> |
|---|
| 44 | <cfargument name="method" type="string" required="Yes" hint="Name of the method to call"> |
|---|
| 45 | <cfargument name="argCollection" type="struct" required="No" hint="Can be called with an argument collection struct"> |
|---|
| 46 | <cfargument name="argList" type="string" required="No" hint="Can be called with an argument list, for simple values only: ex: 'plugin=logger,number=1'"> |
|---|
| 47 | <!--- ************************************************************* ---> |
|---|
| 48 | <cfset var results = ""> |
|---|
| 49 | <cfset var key = ""> |
|---|
| 50 | |
|---|
| 51 | <!--- Determine type of invocation ---> |
|---|
| 52 | <cfif structKeyExists(arguments,"argCollection")> |
|---|
| 53 | <cfinvoke method="#arguments.method#" |
|---|
| 54 | returnvariable="results" |
|---|
| 55 | argumentcollection="#arguments.argCollection#" /> |
|---|
| 56 | <cfelseif structKeyExists(arguments, "argList")> |
|---|
| 57 | <cfinvoke method="#arguments.method#" |
|---|
| 58 | returnvariable="results"> |
|---|
| 59 | <cfloop list="#argList#" index="key"> |
|---|
| 60 | <cfinvokeargument name="#listFirst(key,'=')#" value="#listLast(key,'=')#"> |
|---|
| 61 | </cfloop> |
|---|
| 62 | </cfinvoke> |
|---|
| 63 | <cfelse> |
|---|
| 64 | <cfinvoke method="#arguments.method#" |
|---|
| 65 | returnvariable="results" /> |
|---|
| 66 | </cfif> |
|---|
| 67 | |
|---|
| 68 | <!--- Return results if Found ---> |
|---|
| 69 | <cfif isDefined("results")> |
|---|
| 70 | <cfreturn results> |
|---|
| 71 | </cfif> |
|---|
| 72 | </cffunction> |
|---|
| 73 | |
|---|
| 74 | <!------------------------------------------- PRIVATE -------------------------------------------> |
|---|
| 75 | |
|---|
| 76 | </cfcomponent> |
|---|