[eluser]Marcus Cavalcanti[/eluser]
Hi Everybody,
In my application I have many controllers that extended others controllers, then to include these controllers I use require PHP function in each controller that I need to do this inclusion.
As the code below:
Code:
require_once 'BaseController.php';
class Home extends BaseController {
function Home () {
parent::BaseController();
}
function index () {
}
}
Then I thought about doing this in a more encapsulated way using Hooks. I created a hook 'pre_controller' and in the class associated with this hook I have a code as below:
Code:
class ClassLoader {
private $uri;
function ClassLoader() {
$this->uri =& load_class('URI');
}
function loadDependencies() {
switch ( $this->uri->segment(1) ) {
case 'booking':
require_once APPPATH . 'controllers/search.php';
break;
default:
require_once APPPATH . 'controllers/BaseController.php';
}
}
}
The problem is when I run my application, CodeIgniter reports that the file was not included, where it is concluded that the controller is being called before my hook.
Code:
Fatal error: Class 'BaseController' not found in /home/marcus/public_html/bbbrasil/system/application/frontend/controllers/home.php on line 5
So my question is: with the 'pre_controller' my hook should not be called before any controller?