Aspects In Codeigniter |
[eluser]robert.fulcher[/eluser]
I want to implement the ability to do aspects (or something close to it) in my codeigniter project. Can someone tell me how I might be able to do this. I want to use this for putting logging and notifications into my project. I don't want to scatter the code around the project. I was hoping that somewhere there was a gateway that always gets called in CI and I can then evaluate the class and property being called. Thanks
[eluser]rogierb[/eluser]
You could create a post-controller hook that spit out whatever you need based on a var you set insed your controllers (like $this->aspect) The only catch is the extend the redirect() function to call your post-controller hook before redirecting.
[eluser]ReLexEd[/eluser]
If you extend the base-controller, by creating a MY_Controller.php and put that in the libraries-folder, you could create all these hooks very easily. Have a look at Creating Core System Classess
[eluser]robert.fulcher[/eluser]
The Hooks seems like the way to go. I looked at the documentation and have one question. How do I determine the information about the controller that was triggered? For the post-controller I want to examine the triggered controller and method to determine if I want to actually process the code. Thanks for the great suggestion.
[eluser]attos[/eluser]
Load the url helper and use $this->uri->uri_string();
[eluser]robert.fulcher[/eluser]
Couldn't the URI be unreliable based on the project structure? Is there a guaranteed way to get the controller & method? Thanks
[eluser]robert.fulcher[/eluser]
I have this code: Code: <?php This code will not log a message. Is the issue that it is not matching to the submit? The hook works fine as long as I do not redirect in the submit controller. Thanks
[eluser]robert.fulcher[/eluser]
I did notice that $this->output->enable_profiler(TRUE); separates out the class/method any way to tap into this if the hook does not do that? Thanks
[eluser]robert.fulcher[/eluser]
I just thought I would try one more time and see if anyone has any other ideas. So far I can't get this to work. Is there an actual project that can help with this? Thanks for any info. |
Welcome Guest, Not a member yet? Register Sign In |