Issues

ZF-1831: Add new parameter for dispatcher to add module prefix to controllers for default module

Description

Explanation by Matthew Weier O'Phinney-3: {quote} For those wanting to know why this would be useful, consider the following scenario: * You have developed a 'wiki' module * On another site, you want to re-use this wiki module, and have it be the default module. * OOPS! Because it's the default module, the dispatcher doesn't prepend the module name to the controller, and thus cannot find the controller class. {quote}

Using:


Zend_Controller_Front::getInstance()->setParam('prefixDefaultModule', true);

Patch by me:


Index: Zend/Controller/Dispatcher/Standard.php
===================================================================
--- Zend/Controller/Dispatcher/Standard.php (revision 6029)
+++ Zend/Controller/Dispatcher/Standard.php (working copy)
@@ -283,8 +283,8 @@
             throw new Zend_Controller_Dispatcher_Exception('Cannot load controller class "' . $className . '" from file "' . $file . '" in directory "' . $dir . '"');
         }
 
-        if ($this->_defaultModule != $this->_curModule) {
-            $className = $this->formatModuleName($this->_curModule) . '_' . $className;
+        if ($this->_defaultModule != $this->_curModule || $this->getParam('prefixDefaultModule')) {
+            $className = ucfirst($this->formatModuleName($this->_curModule)) . '_' . $className;
         }
 
         if (!class_exists($className)) { 

Comments

Assigned to Metthew

Duplicates ZF-1808, already scheduled

Resolved in trunk. Passing the front controller or dispatcher parameter 'prefixDefaultModule' will ensure the controllers in the default module are namespaced.