Dean,
Is your utility class dependent on the the base class (e.g. - does it use
âthisâ or the variables scope)? Â If so, then you have a couple of
different ways you can go:
1) use it as a mixin inside your component{} , and forego the class wrapper for
the Utility methods entirely:
include template=âUtilities.cfmâ;
2) use inheritance of the Utilities class on the base class (or the base
classâ super class): Â
component name=âBaseClassâ extends=âUtilityClassâ{}
If itâs not dependent on the base class, you can either:
1) Inject it using a dependency framework like Wirebox
(http://wiki.coldbox.org/wiki/WireBox.cfm - which can run outside of a Coldbox
app), Coldspring, etc. ( I see Nathan just replied to this effect) and just
call the injection mapping in your constructor. Â If there are constructor
arguments the Util class needs, you can set those with your injection framework
and be done with them.
2) If the methods are all static helpers, incorporate it as a mixin to your
Application.cfc, so that the methods become available globally, without scope,
on every request.Â
Jon
Â
On February 6, 2015 at 1:24:03 PM, Dean Lawrence ([email protected]) wrote:
Thanks Byron,
I wasn't wanting my utility class to inherit my base class, I am wanting to
inject the utility class into the base class. I'm trying to get away from
explicitly defining the utility class from within the base class. Since the
base class is not called directly, I don't know how to pass the utility
class in as a required argument during initialization.
On Fri, Feb 6, 2015 at 12:11 PM, Byron Mann <[email protected]> wrote:
>
> Think you might want something like this in your base cfc? I think you'd
> not want the UtilClass to inherit the base class however, or this would
> lead to a circular reference and probably kill the app.
>
> component name='baseClass' {
>
> variables.utilClass = new UtilClass();
>
> }
>
>
>
--
[image: profile picture] *Dean Lawrence*
*President*
Internet Data Technology
*Phone:* 888-438-4381 x701
*Web:* www.idatatech.com
*Email:* [email protected]
Programming | Database | Consulting | Training
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360066
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm