[eluser]Unknown[/eluser]
I'd really like to use a hook, but it seems that forces that be are working against me with regard to how hooks are implemented and more importantly, how libraries are implemented.
By changing the $class and $method globals in the pre_controller hook, I can easily remap on the fly what I want my controller to be. The problem is that I need the session and database libraries to be loaded in order to determine if I should remap or not, but libraries are loaded as part of the controller itself. So there's a bit of a chicken and an egg situation going on.
I thought about reproducing minimal library loading logic from within the hook itself, but I worry about future portability and that this is really descending into the sort of hack that CI should be isolating me from. I'm uncomfortable as it is mucking about with $class and $method.
In the simplest terms, here's what I want to do:
1) A page is requested.
2) The session and database libraries are loaded.
3) Conditional logic is performed.
4) Based on the outcome of the logic:
5) The requested page controller will be executed.
6) A remapped page controller will be executed.
Admittedly, I haven't yet dug too deeply into the library logic of CI to see if autoload libraries are loaded prior to the controller being created. I have a feeling they're not, but that's the next place I'm looking.
Any thoughts would be a great help!