I've just stumbled into a situation where i'd like my aspects to be applied to a method called internally on a proxied cfc
I'm using an aspect to apply security to controller methods, here's an example
function context(rc) {
if(rc.hasID()) context_edit(rc);
else context_list(rc);
}
function context_list(rc) authorize="context_list" {
fw.setView(".context_list");
rc.contexts = RouteService.listContexts();
}
function context_edit(rc) authorize="context_edit" {
fw.setView(".context_edit");
rc.context = RouteService.getContext(rc.id);
}
so depending on if the request is for /context or /context/:id i'm switching the controller method, but as the method call for context_list() or context_edit() are internal the aop proxy doesn't get a chance to intercept them.
given that cfml allows you to dynamically swap methods on a cfc, i'm wondering if there's any way to alter the aspect to replace the method in the target with one that sends the method call via the proxy? does that make sense, or am i talking gibberish :)
I guess i might work something like
- target method gets renamed, eg. originalMethod() --> __proxied_originalMethod()
- proxy injects itself into the target cfc
- proxy replaces original method with new method that calls the proxy, eg.
function originalMethod() {
return variables.__injectedProxy.__proxied_originalMethod();
}
Might something like that work ?
Cheers, Chris