Get Module Settings

Hi guys, I have ModelService, where in the ModelDAO I need to inject
the 'datasources.dsn.name' from in my ModuleConfig.cfc, how can I do
that?

Thanks in adavance

Felipe Serrano

To inject the setting add the following:

component inject {
property name=“MySiteDSN” inject=“coldbox:datasource:mysite”;
}

Be sure to name “mysite” with the name of your dsn in the coldbox config. Then, try adding this so you can see the result as it was injected into your ModelService:

function myDAOFunction() {
writeDump(variables);
abort;
}

You should see a struct of all the settings as variables.MySiteDSN.

Thank you Aaron,

But I thought using that, will retrieve my settings from coldbox.cfc
and not ModuleConfig.cfc, correct?

Thank you! :slight_smile:

Felipe Serrano

Sorry. Misunderstood.

I don’t have an answer for that one. Will have to let one of the other guys chime in.

Thanks.

-A

They are appended to the master configuration so that will work

by doing this: getModuleSettings('modulename').datasources.dsn.name
I retrieve the 'name' of my 'dsn' in the 'datasource' structure inside
my ModuleConfig.cfc

Thank you Aaron and Luis...

I did read the wiki wirebox, and follow "all" instructions and
directions, but...

In my handler (WORKS):
<cfset rc.injector =
createObject("component","coldbox.system.ioc.Injector").init() />
<cfset rc.cart.testservice =
rc.injector.getInstance("modules.cart.model.test.TestService").init() /

When I try to inject (STOP WORKING):
<cfproperty name="dsn" inject="coldbox:setting:dsn" /> or
<cfproperty name="dsn" inject="coldbox:datasource:dsn" />

(I have both values set in: datasources={dsn={name='mydsn'}} and
settings={dsn=datasources.dsn.name} )

Is there a switch to struct my models to do injections using the
cfproperty?

Thanks in advance

Felipe Serrano

Ok guys, finally before pulling the trigger... I found out my mistake:

In my ModuleConfig.cfc I hade two versions of the "this.entryPoint"

First: this.entryPoint = "cart"
Second (about six lines below): this.entryPoint = "cart:home.index"

(taking out the second one, it clear out the error, but since it is
not required I remove both)

Some how, that was stopping my DI within my modules models... All back
to normal again.

Felipe Serrano