I am finally diving into the world of ColdBox modu...
# box-products
a
I am finally diving into the world of ColdBox modules and I'm really digging it. What I can't figure out is how to have Wirebox inject my parent applications model objects into my modules handlers. Is there a config setting for the module to be able to map the parent models folder in addition to my modules models folder?
🙌🏾 1
s
The module should only be mapping models within the module; the parent
config/Wirebox.cfc
would map your parent app's models with something like
mapDirectory( 'model.ORM' ).property( name = 'wirebox', dsl = 'wirebox' );
a
I kinda figured it might be weird because you're breaking encapsulation of the module by reaching outside of it.
c
yeah if you need to map "other" cfc's from an different or older application use the main wirebox config i would have thought. you can also map single objects with map() https://wirebox.ortusbooks.com/configuration/mapping-dsl/mapping-destinations
presumably??? you can do module specific wirebox config but not something i have ever done
a
The parent ColdBox application has WireBox configured to map a models folders outside the webroot. If I configure WireBox to also look at the modules models folder, then autoinject annotations should work, right?
c
module config
autoMapModels = true
what your after?
a
I have that set to true already but the model object isn't getting injected into the handler
I think what I want to accomplish is possible, I just need to fiddle with Wirebox config a bit
c
oh you need to use a property or a wirebox call to actually have it available in the handler
a
Ha! I'm just impatient and had an abort in my init that prevented me from seeing the injection. I added the modules models folder to the Wirebox config and reinit, then voila!
c
ah lol that will cause an issue or two yes!
a
My handler had the property for my service I wanted and I can see it is properly initialized now with the dependancies I was looking for. Thank you for the guidance!