Routing based on standard PHP query string

折月煮酒 提交于 2019-12-05 22:51:50
$front->setRequest($request);

The line only sets the Request object instance. The frontController still runs the request through a router where it gets assigned what controller / action to call.

You need to create your own router:

class My_Router implements Zend_Controller_Router_Interface
{
    public function route(Zend_Controller_Request_Abstract $request)
    {
        $controller = 'index';
        if(isset($_GET['controller'])) {
            $controller = $_GET['controller'];
        }

        $request->setControllerName($controller);

        $action = 'index';
        if(isset($_GET['action'])) {
            $action = $_GET['action'];
        }

        $request->setActionName($action);
    }
}}

Then in your bootstrap:

protected function _initRouter()
{
    $this->bootstrap('frontController');
    $frontController = $this->getResource('frontController');

    $frontController->setRouter(new My_Router());
}

Have you tried: $router->removeDefaultRoutes(), then $request->getParams() or $request->getServer()?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!