[Coldbox 5.x] pass parameters/dependency injection?

Hi,

In my handler I am using property declarations to injectjava classes so I can access the methods in my handler.

A few of the classes require parameters during instantiation it seems. Is there a way to pass them in via property declarations?

I need to pass in the result of a method call for example and in some cases simple strings.

Thanks in advance!

I would recommend switching from constructor args to property injection in your classes for this purpose, but what you want to do is possible, it’s just a bit more work. You have two possible ways to do this. The first one is to put some metadata in the classes WireBox is creating to instruct WireBox what to pass into the constructor when building the instance.

https://wirebox.ortusbooks.com/usage/injection-dsl#constructor-argument-annotation

The second option is to map those CFCs in your WireBox.cfc and declare with the mapping DSL what the init args should be.

Thanks! Appreciate the help as always.