![]() |
Call get_instance() in Hook Class - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: Call get_instance() in Hook Class (/showthread.php?tid=1467) |
Call get_instance() in Hook Class - yllumi - 03-12-2015 Hi everybody, In my application I try to call get_instance() in pre_system hook class. But then error message appeared: Code: A PHP Error was encountered that line refers to get_instance() function in core/CodeIgniter.php. After I check the pre_system hook called before the core/Controller.php included. Any ideas how to solve this? RE: Call get_instance() in Hook Class - Narf - 03-12-2015 You can't "solve" it ... get_instance() returns your controller object, and the controller doesn't exist at 'pre_system'. RE: Call get_instance() in Hook Class - CroNiX - 03-12-2015 To see what's available at what hook points, just open /system/CodeIgniter.php and look for the name of your hook. It will be using _call_hook(name-of-hook); Like: $EXT->_call_hook('pre_system'); To know what's available, it would be anything loaded BEFORE that hook is called. You can see that the controller is loaded way after that hook, so it's not available at that point. The first available hook after a controller is instantiated is "post_controller_constructor" |