According to the Codeignitor docs here: http://ellislab.com/codeigniter/user-guide/general/hooks.html it states:
pre_controller Called immediately prior to any of your controllers being called. All base classes, routing, and security checks have been done.
However, if I create a hook pre_controller hook with:
$hook['pre_controller'][] = array(
'class' => 'tester',
'function' => 'test',
'filename' => 'tester.php',
'filepath' => 'models',
//'params' => array('beer', 'wine', 'snacks')
);
and the file tester.php is:
class tester extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->load->library('migration');
}
public function test()
{
echo "hi";
exit;
}
}
I get this error:
Fatal error: Class 'CI_Model' not found in ******.php
Why is it not loading CI_Model? If I put a require_once('system/core/Model.php'); in the hooks.php file above the pre_controller definition, I get this error:
Fatal error: Call to a member function library() on a non-object in ****.php
Since it's not actually loading the CI_Model, functions such as library() would not work. How can I force it to bootstrap the CI_Model.
The first person that says "Use post_controller_constructor
" will be shot on sight as that does not answer the question. I need it to load BEFORE it runs any constructor functions from the controller classes. I need access to extend the CI_Model class from the pre_controller hook.