2009年4月3日星期五

[fw-mvc] RE: Unmatched routes defaulting to IndexController::indexAction

Just a guess...Are you using "useDefaultControllerAlways" in your front
controller?



--Seth

-----Original Message-----
From: Brenton Alker [mailto:brenton@tekerson.com]
Sent: Wednesday, April 01, 2009 10:05 PM
To: fw-mvc@lists.zend.com
Subject: Unmatched routes defaulting to IndexController::indexAction

Hi,

I have a system setup where I am manually specifying all routes, as
such, I have called $router->removeDefaultRoutes() and added my routes.
After this process, the routes look like --
var_dump($router->getRoutes());

array
'login' =>
object(Zend_Controller_Router_Route_Static)[51]
protected '_route' => string 'login' (length=5)
protected '_defaults' =>
array
'module' => string 'user' (length=4)
'controller' => string 'default' (length=7)
'action' => string 'login' (length=5)
'logout' =>
object(Zend_Controller_Router_Route_Static)[52]
protected '_route' => string 'logout' (length=6)
protected '_defaults' =>
array
'module' => string 'user' (length=4)
'controller' => string 'default' (length=7)
'action' => string 'logout' (length=6)
'root' =>
object(Zend_Controller_Router_Route_Static)[53]
protected '_route' => string '' (length=0)
protected '_defaults' =>
array
'module' => string 'default' (length=7)
'controller' => string 'default' (length=7)
'action' => string 'index' (length=5)

Which is exactly what I want. However, if I hit a different url (eg
/test) It tries to load the IndexController::indexAction (and fails
cause it doesn't exist). While I could create this action to facilitate
a 404 page, shouldn't it just throw an exception when no routes are
matched and let the ErrorHandler do its thing? The frontcontroller
throwExceptions setting doesn't seem to make any difference to this
either.

I am trying to use a PostDispatch plugin to provide dynamic page "cms"
type functionality. Would people consider this a good way to go about
it, or would a "catch-all" (.*) route be better?


--

Brenton Alker
PHP Developer - Brisbane, Australia

http://blog.tekerson.com/

没有评论: