How do I use the getSetting() from within a Modules’ Model?
For example, I have a login module, and there is a UserService.cfc model.
I am trying to access the getDatasource() and getSetting() from within the model.
Is this possible?
Jeremy R. DeYoung
Phone: 615.261.8201
LunarFly DeYoungJD
Jeremy for models the approach is via dependency injection to avoid direct coupling.
You can use the inject dsl to wire in datasoirces, settings or a configuration bean that has all settings.
muji
3
How do I use the getSetting() from within a Modules' Model?
As Luis mentioned, I use DI via Autowire to inject any particular
settings I need into a model CFC
<cfproperty name="thisSetting" inject="coldbox:setting:fieldname" />
Then use getThisSetting() (if you have accessors=true) or
variables.thisSetting to reference it.
For datasource, you an inject from "coldbox:datasource:{alias}".
http://wiki.coldbox.org/wiki/Interceptors:Autowire.cfm#Dependencies_DSL
details the Autowire injects that are possible.