Folks,
I have a base handler (BaseHandler.cfc) under /handlers; and I have a regular handler (MyAdminHandler.cfc) under /handlers/admin.
How can I extend MyAdminHandler.cfc to use BaseHandler.cfc? What is the path? Does it have anything to do with COLDBOX_APP_MAPPING? How to set it up?
Thank you!
Yes you can, we do this on our system to take advantage of some preHandler method routines and injecting some common services like SecurityService into all our handlers.
Simply extend your BaseHandler.cfc to coldbox.system.EventHandler and extend your other handlers to BaseHandler (no path needed if all your handlers reside in the same directory).
Here are the component declaration:
/handlers/BaseHandler.cfc:
component displayname=“BaseHandler” hint=“BaseHandler - Base Event Handler” extends=“coldbox.system.EventHandler” autowire=“true” output=“false” accessors=“true”
{
}
/handlers/MyAdminHandler.cfc:
component hint=“MyAdminHandler- Event Handler” extends=“BaseHandler” output=“false” accessors=“true” autowire=“true”
{
}
Hope this helps.
Thanks Phill. I have figured it out.
/handlers/admin/MyAdminHandler.cfc, I put:
`
component extends=“handlers.BaseHandler” {…}
`