ryan
08/22/2022, 5:44 PMaliaspooryorik
onDIComplete
(which can be a named method or use an annotation). Wirebox will call onDIComplete
once everything is wired up.aliaspooryorik
inject
annotation. Something like <cfargument inject="model" name="dsn" type="string" required="true">
aliaspooryorik
bdw429s
08/23/2022, 4:28 PMbdw429s
08/23/2022, 4:31 PMonDIComplete()
method
• The object is now built and returned
That isn't all the steps, but it's the relevant ones. So your two options are as follows
• inject the required dependencies to the init as constructor args (like John showed above)
• Or move your init logic into an onDIComplete()
methodryan
08/23/2022, 5:55 PMryan
08/23/2022, 7:49 PMonDIComplete()
before), I think I would prefer to use onIComplete()
so that I will not need to modify the CFC getting instantiated. The reason why I don't want to modify the CFC is because I would like to keep the CFC versatile and without any dependencies regarding Coldbox for folks that do not use Coldbox.
So, if I understand correctly, I need to call the init logic in onDIComplete()
somewhere, which I gather would be in the handling CFC that was calling the mixin property injection. Instead of using a mixin, I create a onDIComplete()
function that instantiates the injected cfc's init.bdw429s
08/23/2022, 7:51 PMryan
08/24/2022, 4:29 PMbdw429s
08/24/2022, 4:38 PMI need to place the onDIComplete method in the cfc that calls the other cfc, is that correct?I'm really not sure which is which at this point to be honest. You need to place the onDIComplete method in the CFC which has instantiation logic which you need to run AFTER DI has been processed. So whichever CFC that applies to.... that's the one where you need it, lol
bdw429s
08/24/2022, 4:39 PMryan
08/25/2022, 6:07 PM