Model injection in custom widget not possible

9 views
Skip to first unread message

Christian

unread,
Feb 24, 2020, 5:18:50 AM2/24/20
to ContentBox Modular CMS
Hi,
I am trying to inject a service model from my module into a widget,
The Module is located in /modules_app/<ModuleName> where i divided my models folder into "orm" and "services"
In my ModuleConfig i added both directories to the binder.
My widget is located in: /modules_app/contentbox_custom/_widgets/
When I inject the service model via property name="<name>" inject="<ServiceName>" contentbox tells me that the injected object cannot be found. I also tried it with <ServiceName>@<ModuleName> before adding the static bindings.
When i am loading an instance of my service in the "renderIt" function everything works, however since the service is a singleton this should not be the way to use the service.
Am I missing something?  Are my assumptions of where to place the widgets and my main model right?
Regards
Christian

Christian

unread,
Feb 25, 2020, 3:42:31 AM2/25/20
to ContentBox Modular CMS
I completely forgot to mention the versions I am using:
ContentBox: 4.3.0-snapshot
ColdBox: 5.6.2+1021
Lucee: 5.2.9.31

Christian

unread,
Feb 26, 2020, 9:43:44 AM2/26/20
to ContentBox Modular CMS
My problem just got worse:
I also tried to inject an orm model in a different widget.
My orm models are in an orm folder in the same models folder as my services folder.
The same injection worked in my previously mentioned widget, however in the second widget it is not working anymore...
Upon inspecting the contentbox.log I found that in my service an injection of an orm model failed, however, another injection of a different model worked fine. (Also the service is working when injected)
I think something is wrong with the injections, however as they are working sometimes I cannot see whats failing.

Christian

unread,
Feb 27, 2020, 3:32:55 AM2/27/20
to ContentBox Modular CMS
I just solved the Problem:
In some cases I still had the @<module> appended to my injecion. However since I added the directorry mappings this failed. I removed all @<module> references of injections which pointed at my module. Now things are working fine!
Reply all
Reply to author
Forward
0 new messages