How to get a list of all of my eventhandlers and events

I need to get a list of all of my eventHandlers and there methods/
events. I know I can use this getcontroller().getSetting
('RegisteredHandlers'); to get the event handlers but how do I get the
methods?

I could not find anything that I was looking for so I created a plugin
to do what i want.

<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 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.obj=createobject
('component','eventmanager.handlers.#local.i#')>
        <cfset local.tempArr = getmetadata(local.obj).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>

</cfcomponent>

That is really nice!! How about using getComponentMetadata() and then you don’t have to create the handler objects? CF8 only though.

If you want to contribute this plugin, please let us know so we can post a link to it in our code depot wiki page.

Agreed here! This will be handy for some documentation I may be doing
for a project.

Tom

Yes I would like to contribute this plugin. I made the change that you
suggested and here is the code.
<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>