CB pretty-newb here. I’d like to add a controllerName field to the request context, just listFirst(rc.event, “.”). A number of bits of code want to know that, and it’s silly to recalculate it everywhere.
I tried creating a requestContextDecorator, but I think I’m missing some of the basics.
Conceptually, I just want to do this
rc.controllerName = listFirst(rc.event, “.”);
I tried this in the configure method of my decorator:
var rc = getRequestContext().getCollection();
if (structKeyExists(rc, “event”))
rc.controllerName = listFirst(rc.event, “.”);
That doesn’t work, because rc is always empty struct, and fields I add there don’t show up in the usual rc passed to controllers.
My guess is that this is because configure() is called too early in the request, before the request context is populated
Is there any way to add fields to the request context that are calculated from rc values?
I also tried creating a getControllerName() method in my decorator component, and accessing it from a view helper that has rc passed into it, but the method isn’t available from there. That’s not ideal, since it recalcs every time. (I know it’s a trivial calculation, optimizing it isn’t important, I’m just trying to understand how this stuff works.)
What’s the recommended best practice here?