I have been wondering is it possible to assign another object to $this?
In CodeIgniter I am calling another controller from main controller.
application/controllers/module.php
Class Module extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function _remap($class, $args = array()) {
// doing some checks that is there a valid file, class and method
// assigning the $method.
// including MY_Module class. I'am extending every module from this class.
// then:
$EG = new $class();
call_user_func_array(array(&$EG, $method), array_slice($this->uri->rsegments, 3));
}
}
In called class:
Class Users extends MY_Module
{
public function __construct() {
parent::__construct();
}
public function index() {
// Want to use this class and method like it is a codeigniter controller.
}
}
MY_Module:
Class My_Module {
public function __construct() {
$this =& CI_Controller::get_instance(); // Here is problem.
}
}
I want to use instantiated class' declaretion to My_Module class. So that it wont initialize same libraries and won't spend more resource.
How can I accomplish that?
Thanks for advices.
EDIT: I tried to extend MY_Module from CI_Controller. But since its already instantiated once, it is causing problems.