init arguments

Im building my first module, I just got into an issue where I do not
know how to pass an init argument to a model inside my module project.

I got this structure:

In my ModuleConfig.cfc I got these lines:
<cfset"cartDAO@cart").to("#moduleMapping#.model.cart.CartDAO") />
<cfset"cartGateway@cart").to("#moduleMapping#.model.cart.CartGateway") /

<cfset"cartService@cart").to("#moduleMapping#.model.cart.CartService") /

All is working "fine", but the I got a required argument (dsn) inside
the constructors in my DAO and Gateway models which I have try to
pass on but I just can't.

If I enter the dsn myself all works, that measn I just need to find
the way to pass that argument when I bind them, correct?

Any ideas... I ran out! :frowning:

Felipe Serrano

The wiki docs explain how to use WireBox for arguments in that situation.

Depending on the requirements, you could use the DI on the component to
inject the DSN or other arguments from a config setting or other model /
plugins to read the setting. Or whatever is required, I might suggest you
read this part of the wiki for WireBox it explains a hell of a lot.

But you can certainly use the binder to pass arguments into the init as
well, personally I prefer to do that as a very last resort though.

Andrew Scott

Yes all that he said. You either do DI via annotations on the arguments themselves or via the binder.