0

我如何获得一个 url 参数以及 zend php 框架的重定向 url?假设我在当前页面上有以下 URL

localhost/business/microsoft

当用户单击该页面上的按钮时,它会将他们重定向到具有以下 url 的另一个页面

 localhost/comment/WavvLdfdP6g8aZTtbBQHTw?return_url=%2Fbusiness%2FWavvLdfdP6g8aZTtbBQHTw

我如何编写引导程序 getRouter 以便它可以捕获上述 url 参数?目前的似乎做得不好

$router->addRoute('comment', new Zend_Controller_Router_Route_Regex(
            'business/comment/id=',
            array(
                'controller' => 'business',
                'action'     => 'comment'
            )
            , array(
                'id' => '\d+'
            )
        )); 

谢谢!!!

4

1 回答 1

0

You'll want to write a plugin that captures the request parameters either before (preDispatch()) or after dispatch (postDispatch()) depending on whether or not you might want to intercept and redirect the request.

//basic example of controller plugin
class MyPlugin extends Zend_Controller_Plugin_Abstract
{
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        return $this->getRequest->getParams();
    }
}

Then register your plugin.

于 2012-12-27T10:19:10.950 回答