some additions...
Even after Matthew's corrections in revision 2958, the new named module support 
doesn't seem to work as it is supposed to (in my opinion).

$controller = Zend_Controller_Front::getInstance();
$controller->setParam('useModules', true);
$controller->setControllerDirectory('../application/controllers');
$controller->addControllerDirectory('../application/controllers/Admin', 
'admin');

If I call any of the following: "/" or "/index" or "/index/index" or even 
IndexControllers in my modules, e.g. "/admin/" or "/admin/index", I always get 
the following exception:

Fatal error: Uncaught exception 'Zend_Exception' with message 'File 
"IndexController.php" was not found.' in D:\frameworks\zend\library\Zend.php:175
Stack trace: 
#0 D:\frameworks\zend\library\Zend.php(103): 
Zend::loadFile('IndexController...', Array, true)
#1 D:\frameworks\zend\library\Zend\Controller\Dispatcher.php(585): 
Zend::loadClass('IndexController', NULL)
#2 D:\frameworks\zend\library\Zend\Controller\Front.php(731): 
Zend_Controller_Dispatcher->dispatch(Object(Zend_Controller_Request_Http), 
Object(Zend_Controller_Response_Http))
#3 D:\vhosts\projects\airpane\htdocs\index.php(82): 
Zend_Controller_Front->dispatch()
#4 {main}
  thrown in D:\frameworks\zend\library\Zend.php on line 175

It will find all other controllers, so e.g. "/index/customers" is fine and 
calls the CustomersController in 
"../application/controllers/CustomersController.php".
Another sample: "/admin/mailing" will correctly call the 
Admin_MailingController in 
"../application/controllers/Admin/MailingController.php".
I tried to add a "Default_|Index_" prefix to all non-modular controller class 
names - no success!!

If I reactivate my manually defined router, everything works fine!...

$mainRoute = new Zend_Controller_Router_Route(':module/:controller/:action/*', 
array('module' => 'index', 'controller' => 'index', 'action' => 'index'));
$router = new Zend_Controller_RewriteRouter();
$router->addRoute('mainroute', $mainRoute);
$controller->setRouter($router);

Before your change last night, I was able to use module support with the 
default route by just specifying $controller->setParam('useModules', true);
And besides, with my own router it works though, but it's a bit annoying to 
call "/index/index/action" instead of "/index/action" ("index" was never 
defined as a module and is not found in a module directory. Anything that 
doesn't match a named module should be found in the default controller 
directory set in 
$controller->setControllerDirectory('../application/controllers'); and treated 
as a controller.
Correct me if I'm wrong.

take care
Philip


Philip Iezzi wrote:
> Hi Matthew
> 
> Thanks a lot for extending the modules support in revision 2932!!!
> Actually it pretty messed up my whole directory structure... but hey, that's 
> life and at least we all said good-bye to CVS a long time ago and are working 
> with SVN.
> 
> I hope I got your idea right:
> We now need to explicitly define our modules at the controller setup.
> 
> $front->setControllerDirectory('/path/to/default/controllers');
> $front->addControllerDirectory('/path/to/admin/controllers', 'admin');
> 
> So, here's a URI-to-controller mapping example:
> 
> /address/show         -> action "show"   in "AddressController"  
> (/path/to/default/controllers/AdressController.php)
> /address/delete       -> action "delete" in "AddressController"  
> (/path/to/default/controllers/AdressController.php)
> /admin/customer/kill  -> action "kill"   in "CustomerController" 
> (/path/to/admin/controllers/CustomerController.php) [OLD classname: 
> Admin_CustomerController]
> 
> Nice! But - correct me if I'm wrong - it looks like there's a bug. This won't 
> work:
> 
> /admin/ supposed to call action "index" in "IndexController" 
> (/path/to/admin/controllers/CustomerController.php)
>         instead calls action "index" in "IndexController" 
> (/path/to/default/controllers/AdressController.php)
> 
> 
> same problem if I explicitly call "index" in the URI:
> 
> /admin/index
> OR
> /admin/index/index
> 
> The moduled IndexController just doesn't like me and went to bed early (oh, 
> well, I thought about doing the same tonight - I could use some sleep...).
> 
> Another **weird** thing:
> If I call /index/logout it tries to look for the 
> "<module_path>/LogoutController.php" instead of calling the "logout" action 
> in "/path/to/default/controllers/IndexController.php", while <module_path> 
> being the last module set by $front->addControllerDirectory().
> I would need to call /index/index/logout, even though I have never defined 
> "index" as a module.
> 
> I thought the main idea about the whole thing was "treat me as a controller 
> if I don't look like a module (define by mapping bootstrap Zend_Controller 
> setup)".
> 
> Hope you get my problem.
> Thanks
> Philip
> 

Reply via email to