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

Issue Type: Improvement Created: 2007-08-08T08:44:45.000+0000 Last Updated: 2008-03-21T16:25:34.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Sergey Belov (arikon) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Controller

Related issues: - ZF-1808



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}


<pre class="highlight">
Zend_Controller_Front::getInstance()->setParam('prefixDefaultModule', true);

Patch by me:

<pre class="highlight">
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)) { 


Posted by Thomas Weidner (thomas) on 2007-08-08T09:31:06.000+0000

Assigned to Metthew

Posted by Matthew Weier O'Phinney (matthew) on 2007-11-16T14:46:41.000+0000

Duplicates ZF-1808, already scheduled

Posted by Matthew Weier O'Phinney (matthew) on 2008-02-20T11:07:14.000+0000

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

Have you found an issue?

See the Overview section for more details.


© 2006-2021 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.