Hi everyone,
I’m trying to inject a service into my model to create new() child objects.
ie.
Parent one-to-many Child
Inject ChildService into Parent model so I can call custom function parent.newChild()
and have it call the injected childService.new()
Does that make sense? Should I even be doing this?
I’ve got DI working fine elsewhere, but when I try and do this I get an error similar to the following:
Variable CHILDSERVICE is undefined
My Coldbox.cfc contains:
orm = {
injection = {enabled=true}
};
AND
interceptors = [
…snip…
//Entity Injection
{class=“coldbox.system.interceptors.Autowire”,
properties={
entityInjection = true
}
}
My Application.cfc contains:
…snip…
eventHandling = true,
eventHandler = “model.EventHandler”,
…snip…
The (persistent, ActiveEntity) Parent model has the following property:
property name=“childService” inject=“model:services.ChildService” persistent=“false” scope=“this”;
And attempts to use it like this:
child = childService.new();
Which throws the error above.
Any help appreciated
Cheers
Steve