In Codeigniter, get_instance()
is a globally available function that returns the Controller super-object which contains all the currently loaded classes (it ret
It is necessary to assign by reference because the value of CI_Controller::$instance
is subject to change if another instance of the class is created. The constructor re-assigns self::$instance
each time it runs.
In general, this feels like a bad design pattern and is missing the property of a singleton that limits the class to only one instance, http://en.wikipedia.org/wiki/Singleton_pattern.
It seems possible to type, CI_Controller::get_instance()->$className->$method();
which does seem like more typing that your requested CI()->$className->$method
.
Ultimately, it would make sense to require that only one instance of $instance
can be created and then the need for assigning by reference would be eliminated.