EllisLab/CodeIgniter — pull request #1073 by calvinfroedge (2012-02-23 00:15:12+00:00)
Title: Allow applications to create "Modules" with the same name as the control...

...ler. This is useful for situations where you have controllers which need to be sub classed, but not in all cases. This allows for avoiding code like this (or confusing routing rules):

class employee
{
public function clock(){
$seg = $this->uri->segment(3);
if($seg == 'index')
{
$this->_clock_index();
}
elseif($seg == 'in')
{
$this->_clock_in();
}
}
}

OR the need to create two separate methods for what should essentially be children of the same endpoint:

function clock(){} and function clock_in(){}

This way, a more elegant inheritance structure can be implemented. Employee can still implement methods, but can also have a subfolder which houses other controllers:

Class Employee
- public function __construct
- public function stats
- Clock Controller extends Employee
- public function index
- public function in
- public function out

The other piece needed here is loading the controller which is to be extended. I will send a pull request for that as well - but this route works without breaking anything else.