[coldbox-3.6.0] AOP aspect and custom messagebox plugin

Need an aspect that, when the invocation should NOT execute, will push an error message into flash and redirect.

Guiding Thread:

Some Detail:
I found a thread with Brad and Ben about using a plugin in an AOP Aspect so that when the condition fails, MessageBox is populated with the reason and the next event redirects to the proper action…and this seems a very common and likely scenarios. After hashing through the details, the following key elements were rounded up:

/* Aspect */
component implements=“coldbox.system.aop.MethodInterceptor” accessors=“true” {
// Dependencies
property name=“MessageBox” inject=“provider:CustomMessageBoxDSL”; // !! IMPORTANT PART
property name=“controller” inject=“coldbox”;

any function invokeMethod(required invocation) output=false{
if (blah) {
// continue on to method
return reesults;
} else {
MessageBox.setMessage(‘error’,“You must be logged in and have permissions to perform this action.”);

/* Wirebox */
map(“CustomMessageBoxDSL”).toDSL(“coldbox:myplugin:CustomMessageBox”); // !! IMPORTANT PART

I have tried all sorts of different ways to get access to my custom plugin (which is an extension of the existing MessageBox plugin) and every way has seemed to fail. When I try to implement this solution, I get one of the more common errors:

The CONTROLLER parameter to the init function is required but was not passed in.

(partial stack below). I don’t always know why this error comes up but to me at least, it always means I’ve messed up something in my wiring. I think if I extend the component with FrameworkSuperType maybe just a good oldfashioned getMyPlugin() would solve the problem…or maybe I could inject the plugin service and get it that way?

Reading through the thread (above), I think I understand that the solution was ultimately more about the flash storage…but I’m having trouble getting that far

With so many ways to work around this and that, I just want to know the most useful way…as I said earlier, this is going to be a very common pattern for me. Of course, maybe there is a better way to arrive at this pattern, which I’d also accept as a solution.