Hi folks, just a quick knowledge check here. If I am building an application using ColdBox – which comes with WireBox & LogBox included – in which components do I need to explicitly inject LogBox and which is it already included? Bonus points for showing me where this is explained in the documentation so I can learn how to learn…
My current understanding and experience is that if I am working in a handler then I can just do the following inside my handler without explicitly injecting LogBox:
log.error("Bad stuff just happened.");
However, within a model, I need to explicitly inject it like this (or a variety of other flavors):
Objects such as handlers, plugins, and interceptors that are part of the framework all extend a parent class which extends the framework supertype (the granddaddy class)
If you look in the init() method of these components you can see what helper objects are made available, which often includes cachebox, wirebox, and the controller.
And ALL the methods in the super class are available as well: coldbox.system.FrameworkSupertype
Models are not part of the framework and don’t extend any of these super classes, therefore they don’t automatically have the nice methods or properties that are available in handlers, interceptors, or plugins. So for models, you can use our injection DSL (recommended) or you can extend a system class. For instance, remote CFCs are created by the CF engine not wirebox, so they extend coldbox.system.remote.ColdBoxProxy to get access to the framework.
Fantastic, thank you both – it’s nice when you can develop with confidence that you’re on the proper path! Brad, I really appreciate the additional explanation of why this difference exists. 50 bonus points to you, sir!