2009年4月1日星期三

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknUK3QACgkQ7bkAtAithuvGyQCgxwbI6NRT2/qsXGfxx80/6JGm
iDwAoKrfTdfzIGEXyUwjA74iV3jFVLmk
=YMFH
-----END PGP SIGNATURE-----
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/

没有评论: