Before we deal with injection, I want to address again what I think is a misunderstanding on your part for scan locations. When I said, “You must specify the full path starting at the root of the scan location” here is what I mean.
Let’s say you have a model here:
/model/utility/settingswrapper.cfc
You set the scan location (or model location convention) to “model”
And then, you access it like so:
getInstance( “utility.settingswrapper” )
Note, the “utility” is part of the model path. This is how scan locations work. You point to a root folder and specify the FULL path up to the CFC from inside that folder.
Now, sure you can create a separate scan location for every subfolder inside, but that’s sort of defeating the point. If you like to ask for a model by the model name only (which is my favorite), then we can do that but scan locations are designed for that.
In our /config/WireBox.cfc file we can create an explicit mapping like so:
map( “settingswrapper” ).to( “model.utility.settingswrapper” )
Or that line can just be shortened to the following if you intend for the mapping name to match the name of the CFC
mapPath( “model.utility.settingswrapper” )
And finally, if all the CFCs in your model folder and its sub directories have unique names, you can recursively map the entire folder and its sub directories in a single command:
mapDirectory( “model” )
If this makes sense, we’ll move on to our ORM injection.
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com