Issues

ZF-2429: Controller Module Bug

Issue Type: Bug Created: 2008-01-13T20:44:40.000+0000 Last Updated: 2008-02-20T11:07:30.000+0000 Status: Resolved Fix version(s): Reporter: wangbo (wangbo) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Controller

Related issues: - ZF-1808

Attachments:

Description

I use Controller Module: article, blog and so on. but no default module. because I don't want to use default controller.

when I request a url like 'http://www.foobar.com/article/contents/add', I get some error messenge:

Notice: Undefined index: default in C:\web\zend\library\Zend\Controller\Dispatcher\Standard.php on line 330

I think that default module should be optional.

Comments

Posted by Michal Minicki (martel) on 2008-01-14T06:31:20.000+0000

If you don't use a "default" module, then you should point to a module that is default for you (the one you're accessing by root '/') because that's how the framework works at the moment. For instance:

<pre class="highlight">
$dispatcher->setDefaultModule('blog');

But after looking at the code, I guess Dispatcher would be a good candidate for refactoring. The method which throws an error does too much in my opinion. It's name and signature - getControllerClass(Zend_Controller_Request_Abstract $request) - suggests it returns controller class using Request object. But in fact, it does a lot more (and shouldn't). It could return a class name mid way and what follows should be refactored into more appropriate places.

This shouldn't be happening there:

<pre class="highlight">
        $controllerDirs      = $this->getControllerDirectory();
        $this->_curModule    = $this->_defaultModule;
        $this->_curDirectory = $controllerDirs[$this->_defaultModule];
        $module = $request->getModuleName();
        if ($this->isValidModule($module)) {
            $this->_curModule    = $module;
            $this->_curDirectory = $controllerDirs[$module];
        } else {
            $request->setModuleName($this->_curModule);
        }

Matthew, I could give this class a revamp. Making sure it works as expected and passes all the unit tests. Everything I need is just a green light from you.

Posted by wangbo (wangbo) on 2008-01-14T19:14:29.000+0000

I have a question.

if I code: $dispatcher->setDefaultModule('blog');

then the controller name will be IndexController, not be Blog_IndexController

I think that above two names should be allowed for more consistency.

Posted by Matthew Weier O'Phinney (matthew) on 2008-01-29T12:42:38.000+0000

Duplicates ZF-1808.

Posted by Matthew Weier O'Phinney (matthew) on 2008-02-20T11:07:30.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.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

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

Contacts