I am developing a web-app using zend framework. I like how all the autoloading works however I don't really like the way Zend_Controller names the controllers by default. I am looking for a way to enable zend_controller to understand my controller class named Controller_User stored in {$app}/Controller/User.php . Is there anyway I can do this with least amount of extra code?
+2
A:
This is certainly not a step-by-step answer, but I believe you can accomplish what you want by subclassing the standard dispatcher class, and making a few changes to the functions that deal with the controller directory and controller objects. ZF Ref Guide - Subclassing Dispatcher
Tim Lytle
2008-12-18 17:27:42
A:
a subclassed dispatcher ( quoted from http://cslai.coolsilon.com/2009/03/28/extending-zend-framework/ )
class Coolsilon_Controller_Dispatcher
extends Zend_Controller_Dispatcher_Standard {
public function __construct() {
parent::__construct();
}
public function formatControllerName($unformatted) {
return sprintf(
'Controller_%s', ucfirst($this->_formatName($unformatted))
);
}
public function formatActionName($unformatted) {
$formatted = $this->_formatName($unformatted, true);
return strtolower(substr($formatted, 0, 1)) . substr($formatted, 1);
}
}
Jeffrey04
2009-03-30 07:52:13