Routing zend request through a default controller when controller not found.
Posted
by Brett Pontarelli
on Stack Overflow
See other posts from Stack Overflow
or by Brett Pontarelli
Published on 2010-04-27T01:28:21Z
Indexed on
2010/04/27
1:33 UTC
Read the original article
Hit count: 300
Below is a function defined in my Bootstrap
class. I must be missing something fundamental in the way Zend does routing and dispatching. What I am trying to accomplish is simple: For any request /foo/bar/*
that is not dispatchable for any reason try /index/foo/bar/
. The problem I'm having is when the FooController
exists I get Action "foo" does not exist
. Basically, the isDispatchable
is always false.
public function run() {
$front = Zend_Controller_Front::getInstance();
$request = $front->getRequest();
$dispatcher = $front->getDispatcher();
//$controller = $dispatcher->getControllerClass($request);
if (!$dispatcher->isDispatchable($request)) {
$route = new Zend_Controller_Router_Route(
':action/*',
array('controller' => 'index')
);
$router = $front->getRouter();
$router->addRoute('FallBack', $route);
}
$front->dispatch();
}
© Stack Overflow or respective owner