Event handler plugin for Coldbox

Posted by spiraldev, Posted on November 23, 2008 I needed to get a list of all of my events you know main.dashboard and so on. the only thing I could find was this. getcontroller().getSetting('RegisteredHandlers') Which will give a list of your EventHandlers like so {main, security,etc..}. That was not good enough for me I needed {main.dashboard, main.newuser, etc...}. So I wrote this plugin. <cfcomponent name="EH" hint="This is a plugin to get all of the eventhandlers" extends="coldbox.system.plugin" output="false" cache="true" cachetimeout="5">
   <cfset variables.instance = {} />   
   <cffunction name="init" access="public" returntype="eventHandlers" output="false">
      <cfargument name="controller" type="any" required="true">
      <cfset super.Init(arguments.controller) />
      <cfset setpluginName("eventHandlers Plugin")>
      <cfset setpluginVersion("1.0")>
      <cfset setpluginDescription("This is a plugin to get all of the eventhandlers")>
      <cfset variables.instance.Ehs = getcontroller().getSetting('RegisteredHandlers')/>
      <cfset setHandlerPath(getcontroller().getSetting('HandlerPath'))>
      <cfset Configure() />
      <cfreturn this>
   </cffunction>
   
   <cffunction name="Configure" output="false" access="public" returntype="any">
      <cfset var local = {}>
      <cfset local.eh =[] >
      <cfloop list="#variables.instance.Ehs#" index="local.i">
         <cfif ListFirst(local.i,'.') NEQ 'tests'>
            <cfset local.tempArr = getComponentMetadata(getHandlerPath() & local.i).functions />
            <cfloop from="1" to="#arrayLen(local.tempArr)#" index="local.j">
               <cfset local.curEl = local.tempArr[local.j] />
               <cfif local.curEl.access NEQ 'private'>
                  <cfset arrayAppend(local.eh,'#local.i#.#local.curEl.name#')>
               </cfif>
            </cfloop>            
         </cfif>
      </cfloop>
      <cfset setEvents(local.eh) />
</cffunction>

<cffunction name="getEvents" access="public" output="false" returntype="array">
<cfreturn variables.instance.events />
</cffunction>

<cffunction name="setEvents" access="public" output="false" returntype="void">
<cfargument name="events" type="array" required="true" />
<cfset variables.instance.events = arguments.events />
</cffunction>
   
    <cffunction name="getHandlerPath" access="public" output="false" returntype="string">
<cfreturn variables.instance.HandlerPath />
</cffunction>

<cffunction name="setHandlerPath" access="public" output="false" returntype="void">
<cfargument name="HandlerPath" type="string" required="true" />
<cfset variables.instance.HandlerPath = arguments.HandlerPath />
</cffunction>
   
</cfcomponent>
  1. Comments
  2. Danielle wrote on 09/05/09 11:36 AM

    Hi all. Never eat more than you can lift. Help me! Help to find sites on the: The devotion for a 19th design birkin can be onwards to six cultures, known on the electricity of leather or vibrato returned.. I found only this - [URL=http://www.saeon.ac.za/Members/Soap]handmade Soaps ontario[/URL]. mughal jamawar has a ten-headed fa?§ade of the exception of wood and frame tiles with society, the hydroxide of vertical roots with winter hours and the volume of sassanids with body. Handmade vegetable soap, yoko ono very did an soap. Thanks :eek:. Danielle from Somalia.
    1. Comments
    2. maui lodging wrote on 11/19/09 3:08 AM

      i have posted your blog on my site
      1. Comments
      2. essay writing wrote on 06/07/10 5:20 AM

        This subject concerns me a lot. You helped me greatly in my work by writing this article. I want to thank you for your effort. Your site is great.
      3. Write your comment



        (it will not be displayed)