Jason Ryan
04/05/2023, 8:46 PMmodules folder (which for posterity is a mapped directory in .cfconfig for /modules, and lives in the same folder as Application.cfc)
Have the following WireBox initialization in Application.cfc
function onApplicationStart() {
application.wirebox = createObject("component","wirebox.system.ioc.Injector").init();
application.wirebox.getBinder().mapDirectory("modules").noInit().asSingleton(); // Attempt 1
application.wirebox.getBinder().scanLocations(["modules"]); // Attempt 2
}
Here's where the error comes in:
I have a UserService.cfc component in which I am trying to inject UserData.cfc
component accessors="true" singleton {
property name="UserData" inject="UserData";
function init(){
return this;
}
function getUser(userID) {
return UserData.getUserByID(userID)
}
}
But I get variable UserData does not exist. Seems the injection isn't happening. I was under the impression that mapDirectory or scanLocations would automatically initialize all the CFC's for WIreBox to do it's thang. Am I missing some configuration item here?bdw429s
04/05/2023, 8:58 PMbdw429s
04/05/2023, 8:58 PMJason Ryan
04/05/2023, 8:59 PMnew syntaxbdw429s
04/05/2023, 8:59 PMbdw429s
04/05/2023, 8:59 PMbdw429s
04/05/2023, 8:59 PMJason Ryan
04/05/2023, 8:59 PMJason Ryan
04/05/2023, 9:00 PMapplication.wirebox.getInstance("UserService");bdw429s
04/05/2023, 9:00 PMbdw429s
04/05/2023, 9:00 PMJason Ryan
04/05/2023, 9:01 PMJason Ryan
04/05/2023, 9:01 PMbdw429s
04/05/2023, 9:02 PMbdw429s
04/05/2023, 9:02 PMJason Ryan
04/05/2023, 9:02 PMJason Ryan
04/05/2023, 9:03 PMwirtebox.getInstance is just what I needed, working great now. Thanks!