RE: [coldbox:9489] Re: Wirebox stumbling block

Ben, there are three basic ways that WireBox finds your cfc.

  1. Scan locations: This is an array of directories for WireBox to scan automatically when trying to resolve a cfc’s path by its name. You can put whatever directories you want in this array, but it defaults to “/model”. Scan locations ARE NOT RECURSIVE. This means that model.mycfc will be found, but model.folder.mycfc will not.
  2. Explicit mappings in your wierbox.cfc config file for each CFC. You can tell wirebox about specific CFCs anywhere on your server and give them an alias with the map(“IThinkIllCallItThis”).to(“”);
  3. And finally, my favorite: mapDirectory(“path”). This also lives in the programmatic wirebox.cfc config file and will RECURSIVELY map all CFCs in that folder the first time it starts up. The alias will default to the name of the CFC, but you can override that as well as its scope via metadata/annotations in the CFC itself.
    There many ways to tell WireBox about your cfcs and there are pros and cons of each way. I keep all my CFCs organized in a “CFC” folder, and I have a single mapDirectory(“CFC”). Then I set up the singletons with in the CFCs themselves. This covers 95% of my use-cases.

Basically, if you feel like you want more control over what you are mapping, I would use the map().to().etc() DSL, Oherwise, I would recommend you get started with a big fat mapDirectory(“model”).

Now, when you go to wire in your CFC, all you have to do is

That tells WireBox that you want a piece of your model that has been aliased as PermissionsManager.

Does that all make sense?



Thanks for the explanation Brad. That makes complete sense to me now.

I feel really dumb now because I completely overlooked the
WireBox.cfc. Not sure how I managed to do that.

I should be good now.

Thanks again,

Also you forgot a detail. When you day model:alias
That alias can be an instantiation path or partial path. Since you had
_base.PermissionManager as the path from model that is what you could
have used.


However I would recommend using aliases for better refactoring.