From time to time the question “how can I list all controllers?” pops up. I provided a (untested) solution in the german google group, but yesterday I had to see that it didn’t work (thanks to Kinesis77). So here is the improved code as a component:

// app/controllers/components/controller_list.php
class ControllerListComponent extends Object {
    function get() {
     	$controllerClasses = Configure::listObjects('controller');

        foreach($controllerClasses as $controller) {
            if ($controller != 'App') {
                $fileName = strtolower($controller).'_controller.php';
                $file = CONTROLLERS.$fileName;
                require_once($file);
                $className = $controller . 'Controller';
                $actions = get_class_methods($className);
                foreach($actions as $k => $v) {
                    if ($v{0} == '_') {
                        unset($actions[$k]);
                    }
                }
                $parentActions = get_class_methods(’AppController’);
                $controllers[$controller] = array_diff($actions, $parentActions);
            }
        }

        return $controllers;
    }
}

The usage is simple. Just include the component in the $components array of your controller:

var $components = array('ControllerList');

and call it with:

$this->ControllerList->get()

It returns an array with the following format:

Array
(
    [Pages] => Array
        (
            [0] => display
        )
    [Tests] => Array
        (
            [0] => index
            [1] => groups
            [2] => cases
        )

Update 2008-02-04: Applying Jej’s patch and adapted the component to work with Cake 1.2.