I have a service.cfc that and I’m doing some work using the cookie plugin. For some reason reason I can’t call any plugins from inside that service. I thought in coldBox 3.1 it was already wired? I can call the plugin just fine from the handler or view just not inside my service. Any suggestions? Do I need to inject it?
The one item I left out is that my function is set to remote because I’m calling it via a bind to basically save the cookie when one of the values of my selection options change. Should that make a difference?
Yes I tried that in my second example because I realized that the first wouldn’t work. It still didn’t working using what you wrote below and hence why I am stumped. Is there a way I can see if the injection worked?
I inherited this app so it’s called directorService.cfc located in the app.nba.service folder. nba is the name of the app. Someone else built this back in 2.5. I have been able to inject other items that are mapped in wirebox into the service. For example I have some legacy email functions (emailService.cfc) in that same folder that I inject just fine. It doesn’t give me an error when I reinit. It just can’t seem to inject a plugin.
ok if it is not in a standard convention structure you will need to use the wire box map as you were going to do in the first place.
Or you could copy them one by one into the standard convention for models, it should do no harm unless it is being reference by its full path somewhere else.
Because WireBox will only inject into known locations, and because the service is not in a known location it will not not inject it.
So you have two choices.
Copy the services to a known location.
Use WireBox map like you had planned to do.
Now I think and I am not 100% sure, as I use the standard convention locations, even though I have named these differently to the standards but as far as CB goes they are known to CB.
You may have to add that directory to WireBox, I am not 100% sure on this.
But if you are getting a variable not declared this is your problem, and to test that you can do this right before you try to call the inject variable.
writeDump(cookiePlugin); abort;
or the old way
This will try to dump the variable, if it throws an exception then it was not injected. If it dumps the plugin then there must be something else wrong and you may need to show us the error and stack trace.
Jonathan, I was thinking about this some more, and I think you will need the mapDirectory especially if you have others in there you want to wire up later.
If you do this then you will not need the original wirebox map you tried to do earllier.